How To Switch Java in Centos
* If you need to install a new version of java, download the version from java.sun
* run /usr/sbin/alternatives to change the default java. If you will run the next command you will see which java versions are available:
# /usr/sbin/alternatives --config java There is 1 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java Enter to keep the current selection[+], or type selection number: |
Add the new java to the list of alternatives:
# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_15/bin/java 2 |
Choose the new java as the default:
# /usr/sbin/alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java 2 /usr/java/jdk1.6.0_15/bin/java Enter to keep the current selection[+], or type selection number: 2 |
The same thing you should do with for javac:
# /usr/sbin/alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_15/bin/javac 2 # /usr/sbin/alternatives --config javac There are 2 programs which provide 'javac'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/java-1.4.2-gcj/bin/javac 2 /usr/java/jdk1.6.0_15/bin/javac Enter to keep the current selection[+], or type selection number: 2 |
One Comment
Leave a Reply
I followed this link for java on CentOs
http://wiki.centos.org/HowTos/JavaOnCentOS
After completing all steps
when I execute command java. I get correct output
But when I do javac … command not found.
I tried above mentioned options also.
which javac… give not found