Monday, September 21, 2015

How to Install JDK on Ubuntu 14?

First off download JDK 6
You will get a bin file with the version you may choose by this time I have choose 'jdk-6u45-linux-x64.bin', after we will execute the program and move to another proper directory:

user@user:~$ chmod +x jdk-6u45-linux-x64.bin
user@user:~$ ./jdk-6u45-linux-x64.bin
user@user:~$ sudo mkdir /usr/lib/jvm/
user@user:~$ sudo mv jdk1.6.0_45/ /usr/lib/jvm/


Next of put directory as update alternatives with the priority 1

user@user:~$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_45/bin/java" 1
user@user:~$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_45/bin/javac" 1
user@user:~$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_45/bin/javaws" 1



Securily, regard a correct alternatives on java program and check if there is installed the correct option in the system

user@user:~$ sudo update-alternatives --config java
user@user:~$ sudo update-alternatives --config javac
user@user:~$ sudo update-alternatives --config javaws


user@user:~$ which java
user@user:~$ which javac
 
user@user:~$ which javaws

Edit the next file and add the following lines at the end of the script:


sudo gedit /etc/profile
----------


JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/lib/jvm/jdk1.6.0_45/jre
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH


---------
Finally execute profile to load variable system

 . /etc/profile

update: 25/06/2016

Add reference to jar:

sudo alternatives --install /usr/bin/jar jar /opt/jvm/jdk1.8.0_91/bin/jar 2
sudo alternatives --install /usr/bin/javac javac /opt/jvm/jdk1.8.0_91/bin/javac 2
sudo alternatives --set jar /opt/jvm/jdk1.8.0_91/bin/jar
sudo alternatives --set javac /opt/jvm/jdk1.8.0_91/bin/javac

 

No comments:

Post a Comment