Tuesday, November 18, 2014

Install Oracle JDK 8 on Ubuntu 14.04 LTS

Due to license issue, Ubuntu 14.04 LTS does not come with Oracle JDK. you can check the current java installed by running:

$java -version

To install the latest Oracle JDK 1.8 and set as default JDK on Ubuntu. First download the JDK 1.8 from the Oracle download page:


or


Download the jdk-8u25-linux-x64.rpm (assuming that you have a 64bit Ubuntu installed). As Ubuntu is based on Debian, we need to convert the *.rpm to *.deb fileformat. To do so, install the alien using the following command line in Ubuntu terminal:

$sudo apt-get install alien

After the alien is installed, cd to the download folder containing the jdk-8u25-linux-x64.rpm. Run the following command line:

$alien -k jdk-8u25-linux-x64.rpm --scripts

After the above command line returns, the user should find the jdk-8u25-linux-x64.deb in the same folder. Now run the following command line to install JDK:

$sudo dpkg -i jdk-8u25-linux-x64.deb

After the JDK 1.8 is installed, open the .bashrc file in the $HOME directory:

$cd $HOME
$gedit .bashrc

In the .bashrc opened, add the following lines to the end:

export JAVA_HOME=/usr/java/jdk1.8.0_25/
export PATH=$JAVA_HOME/bin:$PATH

Save and close the .bashrc, now run the following command to update the environment var:

$source .bashrc

Done. we can check the current JDK on Ubuntu to confirm that the current version is indeed Oracle JDK 1.8 by running the following command:

$java -version

which should prints the following lines:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)



No comments:

Post a Comment