How to set the Java version

0

I'm using fedora, and I manually installed java in /usr/java/jdk1.6.0_45/jre, using command "rpm". While there is a default java version in /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java.

If I type "java -version" it shows 1.7.0. And as I installed Java using rpm, update-alternatives --config java still shows only 1.7.0 version.

How could I change the system version to 1.6.0?

I also installed and configured maven, if I typed "mvn --version" it shows correctly:

Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 08:51:28-0500)
Maven home: /usr/local/apache-maven-3.0.5
Java version: 1.6.0_45, vendor: Sun Microsystems Inc.
Java home: /usr/java/jdk1.6.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.3.4-5.fc17.x86_64", arch: "amd64", family: "unix"

Freya Ren

Posted 2013-05-28T18:56:11.207

Reputation: 105

This is the right solution. Edit the environment is not enough. – None – 2013-05-28T19:19:25.500

Answers

5

Set your $JAVA_HOME to point to /usr/java/jdk1.6.0_45 and add /usr/java/jdk1.6.0_45/bin to your $PATH variable.

austin

Posted 2013-05-28T18:56:11.207

Reputation: 758

I think I already set the path to .bashrc file, I don't know why it doesn't work. – None – 2013-05-28T19:02:39.557

@Aubin Hi, I tried the "alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_45/jre 10". Though now I could have two choices, when I change my version and type "java -version", it shows "bash: /usr/bin/java: Is a directory". I typed "which java" and it gives "/usr/bin/java". So do you know where goes wrong? – None – 2013-05-28T19:10:29.540

Hi, problem solved, I made a silly mistake to use the wrong java path. It should be /usr/java/jdk1.6.0_45/bin/java. It works! – None – 2013-05-28T19:18:30.887