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?
-
depends on the path which mainly depends on your operating system (and might therefore be better suited for superuser.com)sfussenegger– sfussenegger2010年03月01日 16:03:10 +00:00Commented Mar 1, 2010 at 16:03
3 Answers 3
Change the PATH variable.
set PATH=c:\java1.5\bin;%PATH%
Comments
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!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