java.exe 总是指向 JRE 的路径而不是 JDK

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5250806/
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 10:13:49  来源:igfitidea点击:

java.exe always point to the path of JRE but not JDK

environment-variablesjava

提问by Leon

I have both jdk and jre installed on my windows 7.

我的 Windows 7 上同时安装了 jdk 和 jre。

I have set the JAVA_HOME to

我已将 JAVA_HOME 设置为

C:\Program Files\Java\jdk1.6.0_23

I have add

我有添加

C:\Program Files\Java\jdk1.6.0_23\bin

to PATH.

到路径。

but the java.exe still pointing to my jre dir, which is

但是 java.exe 仍然指向我的 jre 目录,即

C:\Program Files\Java\jre6\bin

since when I run

自从我跑

java.exe -server

it complains

它抱怨

Error: no `server' JVM at `C:\Program Files\Java\jre6\bin\server\jvm.dll'.

can anyone tell me what else do I need to set?

谁能告诉我我还需要设置什么?

回答by bestsss

since you are on windows, java doesn't work like that. there is a java.exe in some windows directory (%windir% system32 for you)

因为你在 windows 上,java 不能那样工作。在某些 Windows 目录中有一个 java.exe(%windir% system32 给你)

This java.exe actually looks in the registry HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

这个 java.exe 实际上在注册表中查找 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment

PATH won't help ya! Since I tend to get lazy I delete the JRE and create a junctionto the JDK instead.

PATH 帮不了你!因为我比较懒惰,所以我删除了 JRE 并junction为 JDK创建了一个。

回答by maribge

Just remove java.exe from %windir%\system32

只需从 %windir%\system32 中删除 java.exe

回答by Baz1nga

Right click MY Computer> properties > Advanced System Settings > Environment Variables >

右键单击“我的电脑”>“属性”>“高级系统设置”>“环境变量”>

Search for Path..

搜索路径..

Remove the exisiting path and then add yours..

删除现有的路径,然后添加你的..

take care of the semi colon

照顾好半结肠

回答by Helter Scelter

make sure that your JRE/bin directory is not included in your path. the first instance of java.exe found while searching your path will be the one that is executed. if you've added your JDK to the path after the JRE then the JRE will always be picked.

确保您的 JRE/bin 目录不包含在您的路径中。搜索路径时找到的第一个 java.exe 实例将是执行的那个。如果您已将 JDK 添加到 JRE 之后的路径中,则将始终选择 JRE。

you can also explicitly specify the full path to java.exe when invoking java. this will ensure that you always know what java jre/jdk you are invoking.

您还可以在调用 java 时显式指定 java.exe 的完整路径。这将确保您始终知道您正在调用什么 java jre/jdk。

回答by MBU

If you have a 64bit operating system, it will try to use the 64bit jre that is preinstalled on windows 7. You can try using add/remove programs to remove the 64bit jre. I've had this problem several times and I've always fixed it by removing the 64bit jre.

如果您使用的是 64 位操作系统,它会尝试使用 Windows 7 上预装的 64 位 jre。您可以尝试使用添加/删除程序来删除 64 位 jre。我已经多次遇到这个问题,我总是通过删除 64 位 jre 来解决它。