java 已经在使用JDK 1.6的情况下,如何设置JDK 1.5的Path和JAVA-HOME?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6718827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 16:59:58  来源:igfitidea点击:

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

java

提问by manjula selvaraja

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:

我目前使用的是 JDK 1.6,但我现在需要使用 JDK 1.5。我已经安装了 JDK 1.5。我真的不知道设置路径。我尝试在环境变量中设置它:

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.

但是当我在命令提示符中检查版本时,它仍然显示 JDK 1.6。

How do I change it?

我该如何更改?

回答by Andrew Thompson

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

我目前使用的是 JDK 1.6,但我现在需要使用 JDK 1.5。

No, you don't. Use the cross-compilation options, including and especially the -bootclasspathoption, 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.

不,你没有。使用交叉编译选项,包括特别是-bootclasspath选项,Java 6 编译器生成的代码应该与 Java 1.5 兼容,就像它是用 1.5 JDK 编译的一样。

回答by Shilaghae

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.

如果您在编辑路径变量后使用相同的窗口,正如Jayan 建议的那样,请尝试关闭 Window DOS 窗口并打开一个新窗口,然后检查版本。

回答by Asad Rasheed

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 PATHand JAVA_HOMEand their values.

现在您将看到一个系统变量列表。您可以找到PATHJAVA_HOME及其值。

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 Windowsto create system variable in Windows.

版本将是JDK 1.5.xx,现在您可以在Windows 中使用Set JAVA_HOME 变量在Windows中创建系统变量。

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

如果您使用 JDK 1.5 编译代码并使用它运行,这一切都没有问题。否则检查安德鲁的帖子

回答by Jayan

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

您可能必须编辑 PATH 变量才能正确排序条目。