简体   繁体   中英

How to set the Path and JAVA-HOME of JDK 1.5 when we are already using JDK 1.6?

I'm using JDK 1.6 at the moment, but I need to use JDK 1.5 now. I have installed the JDK 1.5. I really don't have an idea to set the path. I tried by setting this in the Environment variables:

JAVA_HOME = C:\Program Files\Java\jdk1.5.0
PATH = C:\Program Files\Java\jdk1.5.0\bin

But still when I check the version in the command prompt it says JDK 1.6.

How do I change it?

I'm using JDK 1.6 at the moment, but I need to use JDK 1.5 now.

No, you don't. Use the cross-compilation options , including and especially the -bootclasspath option, and the code generated by the Java 6 compiler should be as compatible with Java 1.5 as if it had been compiled with a 1.5 JDK.

If you are using the same window after having edited the path variable, as Jayan suggests , try to close the Window DOS windows and open a new one and then check the version.

In command-line windows type:

set JAVA_HOME = C:\Program Files\Java\jdk1.5.0   **hit enter and then type**
set PATH = %JAVA_HOME%\bin   **hit enter and then type**
set

Now you will see a list of system variables. You can find PATH and JAVA_HOME and their values.

If the above values are correct, as you typed previously in a command prompt, type:

javac -version

The version will be JDK 1.5.xx, and now you can use Set JAVA_HOME variable in Windows to create system variable in Windows.

This is all OK if you compile your code with JDK 1.5 and running with it. Else check the post by Andrew .

You may have to edit PATH variable to have the entries correctly ordered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM