Search This Blog

Monday, 23 May 2016

How to add Java environment variable on Linux.

root@kabali:~$ which java  /usr/bin/java

root@kabali:~$ ll /usr/bin/java lrwxrwxrwx 1 root root 22 2009-01-06 19:08 /usr/bin/java -> /etc/ alternatives/java

root@kabali:~$ ll /etc/alternatives/java lrwxrwxrwx 1 root root 36 2009-01-14 08:38 /etc/alternatives/java -> /usr/ lib/jvm/java-6-sun/jre/bin/java

root@kabali:~$ which javac /usr/bin/javac

root@kabali:~$ ll /usr/bin/javac lrwxrwxrwx 1 root root 23 2009-01-14 00:24 /usr/bin/javac -> /etc/ alternatives/javac

root@kabali:~$ ll /etc/alternatives/javac lrwxrwxrwx 1 root root 37 2009-01-14 08:25 /etc/alternatives/javac -> / usr/lib/jvm/java-6-openjdk/bin/javac
=================================================================================


Install new java location by following command:
 root@kabali:/usr/local/java/jdk1.8.0_05/jre#update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_05/bin/java" 1
root@kabali:/usr/local/java/jdk1.8.0_05/jre#update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_05/bin/javac" 1
root@kabali:/usr/local/java/jdk1.8.0_05/jre#update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_05/bin/javaws" 1ws

Set
root@kabali:/usr/local/java/jdk1.8.0_05/jre# update-alternatives --config java

There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
3 /usr/local/java/jdk1.8.0_05/bin/java 1 manual

root@kabali:/usr/local/java/jdk1.8.0_05/jre# update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 auto mode
1 /usr/lib/jdk1.8.0_05/bin/javac 1 manual mode
2 /usr/lib/jvm/java-6-openjdk-amd64/bin/javac 1061 manual mode

root@kabali:/usr/local/java/jdk1.8.0_05/jre# update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws 1061 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws 1060 manual mode
3 /usr/local/java/jdk1.8.0_05/bin/javaws 1 manual mode

root@kabali:/usr/local/java/jdk1.8.0_05/jre# java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)


No comments:

Post a Comment