Windows忽略JAVA_HOME:如何将JDK设置为默认值? [英] Windows ignores JAVA_HOME: how to set JDK as default?
问题描述
如何说服Windows使用JDK而不是JRE?
How do I persuade Windows to use the JDK instead of a JRE?
此问题曾在此处及其他地方提出过:
This question has been asked before, here and elsewhere:
麻烦的是Windows忽略 JAVA_HOME
和它也忽略了这样一个事实,即我将JDK bin目录作为路径中的第一个条目。
The trouble is that Windows ignores JAVA_HOME
and it also ignores the fact that I made the JDK bin directory the first entry in the path.
当我运行 java -version $ c时$ c>从命令行,而不是调用我的JDK 1.6安装,它运行1.7 JRE。
When I run java -version
from the command line, instead of invoking my JDK 1.6 installation, it runs the 1.7 JRE.
我的猜测是这是一个特定于1.7的问题,并且Windows 7正在做一些不应该使用注册表的事情。
My guess is that this is a problem specific to 1.7, and Windows 7 is doing something it shouldn't with the registry.
关于如何解决此问题的任何想法?
Any ideas on how to fix this?
修改:糟糕。当我写路径时,我在上面写了类路径中的第一个条目。抱歉。
Edit: Oops. I wrote "first entry in the classpath" above, when I meant "path". Sorry.
推荐答案
在Windows上, java
可执行文件使用Windows注册表找到要运行的Java的默认版本。
On Windows, the java
executable uses the Windows Registry to locate the default version of Java to run.
运行的 java.exe
副本可通过以下方式找到: PATH
环境变量。除非您采取措施进行更改,否则默认情况下会在Windows目录中找到一个副本。由于此副本不在Java运行时目录中,因此它通过查看注册表来查找它。
The copy of java.exe
to run is found by using the PATH
environment variable. Unless you take steps to change this, by default a copy will be found in the Windows directory. Since this copy isn't in a Java runtime directory, it locates one by looking at the registry.
因此,您需要修改注册表,或者放置版本您希望之前的 $> c $ c>中的Windows目录。
So, you either need to modify the registry, or put the version of Java you want before the Windows directory in your PATH
.
这篇关于Windows忽略JAVA_HOME:如何将JDK设置为默认值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!