2

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.

Java

 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 

Javac

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.

5
  • alternatives --config javac Commented May 27, 2013 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 Commented May 27, 2013 at 17:07
  • That installs a new alternative, it does not set it as the current selected alternative. Commented May 27, 2013 at 22:32
  • Ok I will try and update you on this. Thank you. Commented May 28, 2013 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 ? Commented May 28, 2013 at 12:36

1 Answer 1

2

See 'air-dex' example on this post: https://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 
3
  • 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? Commented Jun 5, 2013 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. Commented Jun 13, 2013 at 21:02
  • The blog post link is broken. Commented Sep 1, 2015 at 22:31

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.