Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have this package of java jdk-7u3-linux-x64.rpm. So I have been doing this normally yum install jdk-7u3-linux-x64.rpm. Then immediately I will do this

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

Next step is this alternatives --config java and pick the latest one. Suddenly this particular machine I am having issue when I run this 2 commands it shows me different version of java and javac causing my programme cant be compiled.

Below is all the java

alternatives --config java

There are 4 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   3           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 4           /usr/java/latest/jre/bin/java

Enter to keep the current selection[+], or type selection number:

Java version is as below

java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

But my javac -version is

javac -version
javac 1.7.0_19

I am very surprise where does the 1.7.0_19 comes from cause my installation version is just 1.7.0_03?

Any idea how to resolve this?

share|improve this question
    
What do you get when you run "which java" and "which javac" ? –  John May 22 '13 at 16:53
    
@John I get /usr/bin/java and /usr/bin/javac –  biz14 May 22 '13 at 17:01
    
Are they symlinks? If so, follow them to their ultimate actual binaries. You can also try "rpm -qf <path>" on each of them to find out what package they are owned by - preferrably using the ultimate binary after following any symlink chain. –  John May 22 '13 at 17:03
    
@What are symlink I am not too sure about this. Ok what I did modified this via update-alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000. Next I run both rpm -qf /usr/java/jdk1.7.0_03/bin/java and rpm -qf /usr/java/jdk1.7.0_03/bin/javac gave me jdk-1.7.0_03-fcs.x86_64 –  biz14 May 22 '13 at 17:09
    
Symlinks are symbolic links. If a file is a symlink, it simply points to another file, saying "That's me over there." Do an "ls -la" on /usr/bin/java and /usr/bin/javac. If they look like one file pointing to another, it's a symlink. Follow the chain with further "ls -la"s until you come to the end. Then run "rpm -qf" against the end path. –  John May 22 '13 at 17:13
show 5 more comments

1 Answer 1

up vote 1 down vote accepted

The alternatives system doesn't always work correctly with third party packages like the Java packages you're installing. You need to either use the CentOS packaged java or create the symlinks yourself without using the alternatives system/command to ensure all links are correct.

share|improve this answer
    
But surprisingly this is the same command I have been using for all my other centos machine and it works. So how to create those symlinks as I have been using alternative all this while. –  biz14 May 22 '13 at 18:09
    
Learn the "ln" command. –  John May 22 '13 at 18:10
    
Will it be right if I just cp from /usr/java/jdk1.7.0_03/bin/javac into /usr/bin/javac ? Why do need the links? –  biz14 May 22 '13 at 18:13
    
I did this ln -s /usr/java/latest/bin/javac /usr/bin/javac ln: creating symbolic link `/usr/bin/javac': File exists –  biz14 May 22 '13 at 18:15
    
any help on how to resolve this issue now? –  biz14 May 23 '13 at 16:09
add comment

Your Answer

 
discard

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.