How to install Oracle JDK 8 on Linux Mint

Linux mint 18 mate comes with open JDk 8 by default. Open JDK and Oracle JDK both have almost the same code of the classes in the Java API. But OpenJDK tends to use open libraries and Oracle JDK tends to use closed ones. And if you want to install Oracle JDK 8 on Linux Mint, please follow the below steps.

Install Oracle JDK 8 on Linux Mint 18

Go to Oracle JDK8 download page. And download the latest linux jdk in .tar.gz format.
Here its (32 bit) jdk-8u102-linux-i586.tar.gz

java-jdk-download-page
Note:change the JDK version in the command according to your jdk version.

Copy your JDK .tar.gz file to your Desktop.

Open Terminal. To open terminal click the Main Linux Mint Menu, then go to system tools and select Terminal or type terminal in the search field or click the Terminal icon in taskbar.

terminal

Then type the below code in terminal and hit enter to extract the .tar.gz file in Home folder.

tar -xvf ~/Desktop/jdk-8u102-linux-i586.tar.gz

After that type below command in terminal to create a new folder.

sudo mkdir -p /usr/lib/jvm/jdk1.8.0

Now type below command to move extracted files in home folder to jdk1.8.0 folder.

sudo mv jdk1.8.0_102/* /usr/lib/jvm/jdk1.8.0/

Type below command in terminal and hit enter.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1

Then type below command in terminal and hit enter.

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1

Then type below command in terminal and hit enter.

sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1

After the successful installation, to check the currently active installed version of java, type the below command.

java -version

If it still shows as openJDK, type the below command to check, how many java versions are installed on your system.

sudo update-alternatives --config java

java-config

The * before the number shows the default active java version. To change it, type the your oracle jave number and press enter to active it . Here our installed Oracle JDK is in 2.

Also Read:  How to Install WildFly Application Server on Ubuntu

To config Javac use the below command and select.

sudo update-alternatives --config javac

Then check your default java and javac by using below command.

java -version
javac -version

java-version-check

If you liked this article, please subscribe to our YouTube Channel. You can also stay connected with us on X (Twitter) and Facebook.



This Post Has 3 Comments

  1. aamir

    thank you so much it was really helpful

  2. Siarex

    I am so thankful, that i have to write this comment. Thank you.

  3. Antonio

    thank you! the most useful way of explaining things I’ve ever seen.

Leave a Reply