Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to installing on Centos java from Oracle. Following are my steps.

yum install /usr/local/jdk-7u3-linux-x64.rpm

alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000

alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000

alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000

alternatives --config java I pick the latest version here.

The problem now only my java is pointing to the new version wheras the javac is not pointing to it below is how I trace for java and javac.


 ls -la /usr/bin/java lrwxrwxrwx. 1 root root 22 May 22 13:09 /usr/bin/java -> /etc/alternatives/java

 ls -la /etc/alternatives/java lrwxrwxrwx. 1 root root 25 May 22 13:09 /etc/alternatives/java -> /usr/java/latest/bin/java


ls -la /usr/bin/javac lrwxrwxrwx. 1 root root 23 May 22 11:37 /usr/bin/javac -> /etc/alternatives/javac

 ls -la /etc/alternatives/javac lrwxrwxrwx. 1 root root 48 May 22 11:37 /etc/alternatives/javac -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javac 

Any solution to overcome this? I have tried previously on other machines on Centos 6.3 works fines.

share|improve this question
alternatives --config javac – jordanm May 27 '13 at 17:06
ok so wat should I do just the right one is it? But why this did not work alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000 – biz14 May 27 '13 at 17:07
That installs a new alternative, it does not set it as the current selected alternative. – jordanm May 27 '13 at 22:32
Ok I will try and update you on this. Thank you. – biz14 May 28 '13 at 3:28
Great it is working well now. So should I make sure each time I install java to pick to set both java and javac? I would like to confirm the rest of the steps are they ok ? – biz14 May 28 '13 at 12:36
up vote 1 down vote accepted

See 'air-dex' example on this post: http://askubuntu.com/questions/159575/how-do-i-make-java-default-to-a-manually-installed-jre-jdk . Note: sometimes people install Java JDK's into '/usr/lib/jvm', and as you can see in the output on my blog post, the system came with default JVMs in this location, but personally I don't recommend that for a JDK. Maybe I would choose '/usr/lib/jvm' if it was a JRE I was installing. If you wanted an alternative location for JDKs and JREs, I would choose either:

   1. /usr/java/
   2. /opt/java/

If I were comparing to windows, I might say:

JDKs: /usr/java = C:\Java
JREs: /usr/lib/jvm = C:\Program Files\Java
Alt:  /opt/java = E:\Java
share|improve this answer
I saw your blog but you are using rpm I used yum install is that better ? So I should config both java and javac right. How about the alternatives should I still set them? – biz14 Jun 5 '13 at 4:58
There is a "alternatives-java" command that you can use (instead of plain 'alternatives') that might be capable of updating all the symlinks for all the programs within a particular JDK. I've not tried it yet. Using rpm, Yum, or whatever, the install location may vary depending on the opinion of the person who made the installer. I always prefer .bin (or .zip) archives because you can unzip them to wherever you want and you can be more intentional about it. – djangofan Jun 13 '13 at 21:02
The blog post link is broken. – Mike Partridge Sep 1 '15 at 22:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.