24.6 C
Jaipur
Wednesday, September 22, 2021

How to Install Oracle Java 17 LTS On Ubuntu, Debian, Linux Mint Or Pop!_OS Via APT PPA Repository

Must read

Oracle Java 17 LTS has been released recently, and is now available to install from the Linux Uprising Oracle Java PPA on Ubuntu, Debian, and Linux distributions based on these, such as Pop!_OS, Linux Mint, Zorin OS, etc.

Java 17 is the latest long-term support (LTS) release, and with it, the license has changed, the binaries being free (no cost) to use in production and free (no cost) to redistribute until a full year after the next LTS release. Previously (from Oracle Java 11 until now), Oracle Java used a commercial license that allowed downloading and using it at no cost for development and testing only, but it required paying a fee to use in production.

If you prefer to use open source JDK builds, check out those offered by AdoptOpenJDK or Zulu OpenJDK.

I’d like to note that even though Oracle Java 17 can be redistributed, the Launchpad PPA terms don’t seem to allow packing it into a PPA due to its license. So the Linux Uprising Oracle Java PPA continues to use a script that automatically downloads Oracle Java (the binaries are not hosted in the Launchpad PPA).

This Oracle Java 17 installer is based on the Web Upd8 Java package (so the credits go to its original creators), with minor modifications. This package automatically downloads, installs (with some tweaks such as better font rendering, add applications menu entries, etc.) and optionally sets Oracle Java 17 as the default Java (runs update-alternatives, exports the JAVA_HOME environment variable, etc.) on your system. 

Oracle does offer DEB packages for Oracle Java, however, these packages simply copy the Java binaries to /usr/lib/jvm, without doing anything else, so it’s exactly the same as copying the Java directory to that location yourself.

Using this PPA you can install Oracle Java 17 for x64 and aarch64 architectures.

You might also like: How To Install / Switch Between Multiple Java Versions Using SDKMAN

How to install Oracle JDK 17 On Ubuntu, Debian, Linux Mint, Pop!_OS or Zorin Os using an APT PPA repository

Add the Linux Uprising Oracle Java PPA repository and update the software sources on Ubuntu, Linux Mint, Pop!_OS or Zorin Os using the following commands:

sudo add-apt-repository ppa:linuxuprising/java

sudo apt update

Add the Linux Uprising Oracle Java PPA repository (and its key) and update the software sources on Debian and other Linux distributions based on Debian (but not Ubuntu and Ubuntu-based) using:

su -

echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu focal main" | tee /etc/apt/sources.list.d/linuxuprising-java.list

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A

apt-get update

exit

Now you can install Oracle JDK 17 on Debian / Ubuntu and Linux distributions based on these:

  • Install and make Oracle JDK 17 the default JDK version:

sudo apt install oracle-java17-installer --install-recommends

  • Install but don’t make Oracle JDK 17 the default JDK version:
sudo apt install oracle-java17-installer --no-install-recommends

You can control if Oracle JDK 17 is the default JDK version (runs update-alternatives, exports the JAVA_HOME environment variable, etc.) or note with the help of the oracle-java17-set-default package. If this is installed, Oracle JDK 17 is set as default; remove this package, so Oracle Java 17 is not set as default (unless it’s the only Java version on the system).

This package is set as a recommended package for the Oracle Java 17 installer, that’s why installing oracle-java17-installer with --install-recommends also installs oracle-java17-set-default.

To check which Java version is set as default on your system, you could run java -version and / or javac -version. Example with output that shows Oracle Java 17 set as default:

$ java -version
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)

Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)

$ javac -version
javac 17

In some cases, the installer may fail to download the Oracle Java 17 .tar.gz archive from Oracle. There are multiple possible issues for this: you’re behind a router / firewall that prevents this, your Internet connection went down during the download process, etc. 

To work around this, you can download this file yourself from Oracle by other means, e.g. by going to a friend’s house, using a web browser with a proxy, etc., and then placing the downloaded Oracle Java 17 .tar.gz file in /var/cache/oracle-jdk17-installer (create this folder as root if it doesn’t exist), then install the oracle-java17-installer package from the Linux Uprising PPA as explained above.

This way, the Oracle Java 17 installer uses the local archive instead of trying to download it itself. Make sure the downloaded Oracle Java 17 .tar.gz and the Oracle Java Installer package from the PPA are both the same version, or else this won’t work.

How to accept the Oracle Java 17 license automatically

Downloading and installing Oracle Java 17 requires the user to accept a license. In some cases, like when using this in an automated script, you may want to automatically accept the license using a command. You can do that by using:

echo oracle-java17-installer shared/accepted-oracle-license-v1-3 select true | sudo /usr/bin/debconf-set-selections

If that doesn’t work, also try this command:

echo oracle-java17-installer shared/accepted-oracle-licence-v1-3 boolean true | sudo /usr/bin/debconf-set-selections

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -

Latest article