Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

java - Windows ignores JAVA_HOME: how to set JDK as default?

How do I persuade Windows to use the JDK instead of a JRE?

This question has been asked before, here and elsewhere:

How do I set the default Java installation/runtime (Windows)?

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.

When I run java -version from the command line, instead of invoking my JDK 1.6 installation, it runs the 1.7 JRE.

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.

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

On Windows, the java executable uses the Windows Registry to locate the default version of Java to run.

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.

So, you either need to modify the registry, or put the version of Java you want before the Windows directory in your PATH.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...