DEV Community

Alex Jesus
Alex Jesus

Posted on

48

Como intalar o Java JDK 17 no Ubuntu 22.04

Java 17 LTS é a versão mais recente de suporte de longo prazo para a plataforma Java SE. O JDK 17 é gratuito(1) para uso em produção e distribuição, e irá receber atualizações pelo menos até setembro de 2024.

Esta versão mais recente inclui o JDK 17, que fornece um ambiente para a criação de aplicativos usando a linguagem de programação Java, testando e executando os programas Java.

Aqui, veremos como instalar Java JDK 17 em Ubuntu 22.04.

Instalando o OpenJDK 17

O OpenJDK possui pacotes separados para o JDK (Java Development Kit) para o desenvolvimento de aplicativos Java e o JRE (Java Runtime Environment) para a execução de aplicativos Java.

Para atualizar o índice do repositório, execute o seguinte comando no terminal:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Em seguida, instale o pacote OpenJDK ou JRE conforme o requisito:

  • Para instalar o OpenJDK 17 JDK, execute o seguinte comando:
sudo apt install -y openjdk-17-jdk
Enter fullscreen mode Exit fullscreen mode
  • Para instalar o OpenJDK 17 JRE, execute o seguinte comando:
sudo apt install -y openjdk-17-jre
Enter fullscreen mode Exit fullscreen mode

Instalando o Oracle JDK 17

Primeiro, instale dependências para a instalação do Oracle JDK 17 usando os seguinte comandos:

sudo apt update;
sudo apt install -y libc6-x32 libc6-i386
Enter fullscreen mode Exit fullscreen mode

Em seguida, faça o download do Oracle Java JDK 17 usando o comando wget:

wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.deb
Enter fullscreen mode Exit fullscreen mode

Por fim, instale o Oracle Java JDK 17 usando o comando dpkg:

sudo dpkg -i jdk-17_linux-x64_bin.deb
Enter fullscreen mode Exit fullscreen mode

Em alguns casos, pode ser necessário instalar o Oracle JDK 17 no PATH localização.

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-17/bin/java 0;
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-17/bin/javac 0;
sudo update-alternatives --set java /usr/lib/jvm/jdk-17/bin/java;
sudo update-alternatives --set javac /usr/lib/jvm/jdk-17/bin/javac
Enter fullscreen mode Exit fullscreen mode

Verificando a instalação do Java JDK

java -version && javac -version
Enter fullscreen mode Exit fullscreen mode

Saída:

java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)
javac 17.0.6
Enter fullscreen mode Exit fullscreen mode

Espero que tenham aprendido a instalar Java JDK 17 em Ubuntu 22.04, qualquer dúvida/sugestão/crítica só deixar aquele comentário! 🙂

Abraços []’s

1: Licença de Termos e Condições Oracle No-Fee (sem taxa)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay