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 just installed jdk1.6.0. I have tried multiple ways to set the path variable and make java 1.6 my new running version. And nothing is working. Running centos5 virtual machine.

alternatives --config java returns the following:

  Selection    Command
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.4.2-gcj/bin/java

java -version returns the following:

java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)

echo $PATH returns the following:


1.6.0 is installed in the following location: /usr/local/testing/jdk1.6.0_23/bin

share|improve this question

Try removing /opt/j2sdk/bin and /usr/local/testing/jdk1.6.0_23/bin from your PATH.

When you ran alternatives --config, it should have changed /usr/bin/java to point to the 1.6.0 version.

If you add them to PATH and are using alternatives, you will have two places to configure things, and it will get confusing.

share|improve this answer
up vote 1 down vote accepted

I figured this out. I just appended the new java path to the beginning of my path variable instead of the end and it worked.

export PATH=/usr/local/testing/jdk1.6.0_23/bin:$PATH

That worked. Now i am going to set in my script so it will do automatically.

share|improve this answer

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.