Installing Oracle Java 1.8 on Ubuntu 12.4 64bit

Download Oracle Java 1.8 64 bit for unix from  here.

tar -xvf ~/Downloads/jdk-8u40-linux-x64.tar.gz
sudo mkdir -p /usr/lib/jvm/jdk1.8.0

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

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

sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

mkdir ~/.mozilla/plugins/

ln -s /usr/lib/jvm/jdk1.8.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

Setting JAVA_HOME
================
sudo su
which java
gedit .bashrc
#add the following lines
JAVA_HOME=/usr/lib/jvm/jdk1.8.0
export JAVA_HOME
PATH=$PATH:$JAVA_HOME
export PATH=$PATH:/usr/lib/jvm/jdk1.8.0/bin
export PATH

echo $JAVA_HOME

java -version 

Additional step on systems on which sudo clears or restricts environment variables, you also need to add the
following line to the /etc/sudoers file: 

sudo gedit /etc/sudoers

Defaults env_keep+=JAVA_HOME

sudo env | grep JAVA_HOME

No comments:

Post a Comment