Wednesday, February 20, 2019

Install OpenJDK on Linux Mint/Ubuntu

OpenJDK (https://openjdk.java.net/) provides open-source builds of the Java Development Kit, an implementation of the Java SE Platform under the GNU General Public License, version 2, with the Classpath Exception.

Commercial builds of JDK from Oracle under a non-open-source license, for a wider range of platforms, can be found at the Oracle Technology Network.

This video show how to Install OpenJDK 11.0.2 on Linux Mint 19.1. The OpenJDK will be stored in /opt/java directory, and set as default. It should be work on other Ubuntu variants also.


Oracle's OpenJDK JDK binaries for Windows, macOS, and Linux are available on release-specific pages of jdk.java.net as .tar.gz or .zip archives.

As an example, the archives for JDK 11 (currently 11.0.2) may be found on https://jdk.java.net/11/.

- Visit https://jdk.java.net/11/ to download Linux / x64 build.

- Change to the downloaded directory, it's ~/Downloads in my case.

- Extract the downloaded file, openjdk-11.0.2_linux-x64_bin.tar.gz.
$ tar -zxvf openjdk-11.0.2_linux-x64_bin.tar.gz

-  Create a folder in /opt/java where jdk will be stored.
$ sudo mkdir -p /opt/java

- Move the extracted folder to /opt/java
$ sudo mv jdk-11.0.2 /opt/java

- Set default java and javac using update-alternatives:
$ sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk-11.0.2/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /opt/java/jdk-11.0.2/bin/java 1
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java

There are 2 choices for the alternative java, enter the selection of "1", corresponding to the number of /opt/java/jdk-11.0.2/bin/java.



may be interested:
Install JetBrains Toolbox App on Linux, and also Android Studio and IntelliJ IDEA (Java IDE)

No comments: