Saturday, October 24, 2015

Download and Install JDK8 on Ubuntu 15.10 using update-alternatives, and also set JAVA_HOME


This post show how to Install JDK8 on Ubuntu 15.10 (running in VirtualBox hosted on Windows 10).

To download Oracle JDK:
- visit Java SE Downloads page.
- Click to download Java Platform (JDK).
- Accept agreement and sselect download file, jdk-8u65-linux-x64.tar.gz.

Download and unpack in your local storage. /home/eric/jdk1.8.0_65 folder for me.

Setup java and javac update-alternatives:
Run the command:
$ sudo update-alternatives --install /usr/bin/javac javac /home/eric/jdk1.8.0_65/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /home/eric/jdk1.8.0_65/bin/java 1

$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java

Where /home/eric/jdk1.8.0_65 is the folder of jdk.

Check the video.


Set JAVA_HOME also:

Setup JAVA_HOME and path to JDK on Linux (Ubuntu in this example), edit the file .bashrc
$ nano .bashrc

Add the line:
export JAVA_HOME=<path to jdk>
export PATH=$JAVA_HOME/bin:$PATH

Where <path to jdk> is the path to the installed JDK.




Alternatively, you can install also Install Oracle java8 on Ubuntu 15.10 via PPA.

No comments: