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

一世执手 提交于 2020-01-10 19:16:19

问题


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

I have set the JAVA_HOME to

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

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?


回答1:


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

This java.exe actually looks in the registry 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 junction to the JDK instead.




回答2:


Just remove java.exe from %windir%\system32




回答3:


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




回答4:


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.

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.




回答5:


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.



来源:https://stackoverflow.com/questions/5250806/java-exe-always-point-to-the-path-of-jre-but-not-jdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!