Loading...
понеділок, 28 жовтня 2013 р.

Changing the default Java for linux

I have an linux OS (CentOS 5.6) installed on my machine. And I have worked with java 1.4.2 there but now I'm going to use new JDK 1.6. I have installed java 1.6.0, but running
#java -version
I still got
1.4.2.
How to fix it?
Also id you tried some manual edition, you can get the following error:
# java -version
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
We are going to fix this issue as well
So, lets start an alternatives application with --install key and specify where the new version of java is installed. Let's assume the new java folder is  /usr/local/jdk1.6.0_45/ and the old one is  /usr/local/jdk1.4.2/

So, type:
# alternatives --install /usr/bin/java java /usr/local/jdk1.6.0_45/bin/java 2
This says to Linux that we have installed new java and executable file is  /usr/local/jdk1.6.0_45/bin/java and now we are going make selection of the default java:
#alternatives --config java
You will see the following:
There are 2 programs which provide 'java'.

Selection Command
-----------------------------------------------
* 1  /usr/local/jdk1.4.2/bin/java
+ 2 /usr/local/jdk1.6.0_45/bin/java
 Enter to keep the current selection[+], or type selection number:

The dafault one is marked by *, and you just have to enter the number of line with desired version (2 in our case)
Checking it out:
# java -version
java version "1.6.0_45"

0 коментарі:

 
TOP