简体   繁体   中英

How Does Eclipse find the JRE or JDK locaton?

According to the Eclipse FAQ. I read that

Eclipse DOES NOT consult the JAVA_HOME environment variable.

My doubt is how does eclipse initializes the Virtual Machine . It does not know the location of Java . My eclipse.ini file does not have -vm configuration. Still I am able to run eclipse.

The Source

UPDATE

According to Eclipse Installation Guide . Eclipse does not write entries to the Windows registry .

As far as I know, to invoke the JVM, Eclipse executes the java command, so, if it's at your system execution path, Eclipse won't need to find the instalation directory.

To check, you can start a OS shell and execute the next command (from any location):

> java -version

EDIT: I was (partially) wrong. From the FAQ ( http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM )

If a JVM is installed in the eclipse/jre directory, Eclipse will use it; otherwise the launcher will consult the eclipse.ini file and the system path variable

So, Eclipse first looks inside its eclipse/jre dir for installed VMs, if empty, consults the eclipse.ini file, and at last, looks at the system path.

Even Help->Installation details->Configuration would give you the exact version and type of jvm you are using . Here it is clearly given in System Properties

Eclipse will run using whatever version of JRE you have installed. To see/edit the version being used, go to Preferences -> Java -> Installed JREs

Or just run a java program in Eclipse. Eclipse will show the full path of javaw command it is using.

Eclipse looks for system Path variable to get the installed JVM. It depends upon how you have defined path variable. Order in which several versions have been defined in path does matter ie if jdk1.5/bin is set before jdk1.6/bin, system will pick 1.5 version when you execute java -version on cmd

Solved!

1) downloaded and installed 64-bit versions of both the ADT for Android (Eclipse) and JDK Java bundle

2)updated the PATH environmental variables (Win Control panel...System...advanced opt...Envir.variables) In my case it now looks like this: C:\\Program\\Java\\jre7\\bin\\client\\jvm.dll;C:\\Program\\Java\\jdk1.7.0_21\\bin

(no backslash after the \\bin directory)

These days on WIN64, oracle creates a couple of new directories and adds them to your path. The one eclipse will default to is the second directory you specify in the installation process, because that gets loaded at the head of the path ahead of your JAVA_HOME. It is confusing why they ask you for two directories, I have no answer for that. I blew away the second directory, removed the two added directories from the path, configure my JAVA_HOME environment variable (in my case already on the path pointing to an older version) accordingly, and eclipse is good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM