1

I have two versions of Java setup for development. One is 1.5 and the other obviously is 1.6.

Now when I type java -version it displays up 1.6

What should I change so that it points to Java 1.5?

1
  • depends on the path which mainly depends on your operating system (and might therefore be better suited for superuser.com) Commented Mar 1, 2010 at 16:03

3 Answers 3

6

Change the PATH variable.

set PATH=c:\java1.5\bin;%PATH%
Sign up to request clarification or add additional context in comments.

Comments

1

On Windows:

1) set your JAVA_HOME environment variable to the 1.5 location, one level above the /bin dir, e.g. C:\myjava5dir, not C:\myjava5dir\bin

2) then set your PATH environment variable to include %JAVA_HOME%\bin

3) be sure to start a new DOS prompt to pick up the changes

Also ensure you clear any other existing references to your jdk in PATH.

2 Comments

JAVA_HOME is not actually required by any JDK itself. Some third-party applications use it (for example the Tomcat startup scripts use it), but Java itself doesn't need and/or use it at all!
...and is also good for updating multiple dependencies with one change when you want to flip between, say, Java versions 1.5 and 1.6. But quite right Joachim, it's not strictly essential, no.
1

On Ubuntu (and similar):

$ update-java-alternatives --list
java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun
$ update-java-alternatives --set java-1.5.0-sun

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.