How to Install Oracle Java JDK in Ubuntu Linux

Copy and decompress oracle Java to /usr/local/java

$ sudo mv jdk1.8.0_05/ /usr/local/java

Edit profile:

$ sudo gedit /etc/profile &

Scroll down to the end of the file using your arrow keys and add the following lines below to the end of your /etc/profile file:

JAVA_HOME=/usr/local/java/
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Inform your Ubuntu Linux system where your Oracle Java JDK/JRE is located. This will tell the system that the new Oracle Java version is available for use.

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/bin/javaws" 1

Inform your Ubuntu Linux system that Oracle Java JDK/JRE must be the default Java.

$ sudo update-alternatives --set java /usr/local/java/bin/java
$ sudo update-alternatives --set javac /usr/local/java/bin/javac
$ sudo update-alternatives --set javaws /usr/local/java/bin/javaws

Reload your system wide PATH /etc/profile by typing the following command:

 $ sudo bash /etc/profile

Verify:

$ java -version
java version "1.8.0_31"

You can install Oracle Java in Ubuntu Via PPA Repository:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Switch your java to Java 8:

sudo update-java-alternatives -s java-8-oracle

Setting Java environment variables

sudo apt-get install oracle-java8-set-default

Comments

Popular posts from this blog

Check MySQL query history from command line

Installing chocolatey on Windows