4

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.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
MaheshVarma
  • 2,081
  • 7
  • 35
  • 58
  • It probably checks the registry - at least on Windows. –  Aug 28 '13 at 12:25
  • 1
    It is worth noting that Eclipse does not write entries to the Windows registry . see the source above. – MaheshVarma Aug 28 '13 at 12:28
  • 1
    I didn't say it would *write* to the registry, only that is *reads* the registry as the location (of a properly installed) JRE is available there –  Aug 28 '13 at 12:29
  • @a_horse_with_no_name On Windows, `system32\java.exe` is a stub which looks up the Registry to resolve the active JDK. I would very much doubt that Eclipse does this on its own. – Marko Topolnik Aug 28 '13 at 12:30

7 Answers7

12

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.

Tomas Narros
  • 13,390
  • 2
  • 40
  • 56
  • 1
    either that or it checks the system path (which the operating system would do when calling the javaw command, it won't call the java command as it doesn't want a console to launch) – jwenting Aug 28 '13 at 12:35
  • @jwenting You are right, it's the javaw process (without a console). – Tomas Narros Aug 28 '13 at 12:38
  • @TomasNarros What if it it not at the system execution path? How does it find the location of `javaw` tool? – MaheshVarma Aug 28 '13 at 12:39
  • @TomasNarros You mean eclipse consults PATH environment variable? – MaheshVarma Aug 28 '13 at 12:41
  • @Samuel #1 Then surely the eclipse laucher will show an error dialog or whatever. Never seen it as the Java installation registers the bin folder at the system path. #2 And no, not exactly: Eclipse launches the javaw command and it's the system who resolves it – Tomas Narros Aug 28 '13 at 12:42
2

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

Sagar
  • 159
  • 2
  • 17
1

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

Jitesh
  • 232
  • 2
  • 9
  • This is the only correct answer. In fact my javaw path is: `C:\Users\Marco\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_19.0.2.v20230129-1123\jre\bin\javaw.exe` – Marco D.G. Mar 06 '23 at 10:27
0

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 i.e. if jdk1.5/bin is set before jdk1.6/bin, system will pick 1.5 version when you execute java -version on cmd

Ankit Pandoh
  • 548
  • 5
  • 14
0

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)

  • 1
    Thanks for helping at StackOverflow. Nice to create an answer for this question, even if, or especially if, you are the questions authour. Your phrasing sounds like that is the case. However asker account and answerer account are different (which afaik is not against any rule, just confusing). Can you explain or rephrase, to avoid that confusing impression? – Yunnosch May 15 '17 at 19:40
0

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.

theRiley
  • 1,077
  • 13
  • 16
-1

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

  • No, this is unrelated to OP's question. This is about the JRE used to start the code you are developing within Eclipse. – Marko Topolnik Aug 28 '13 at 12:33
  • @KeithMadsen I guess my question is clear. What if we run for the first time? As per doc. eclipse does not contact environment variables. Then how does eclipse know where the JRE location is? If we run eclipse for the first time? – MaheshVarma Aug 28 '13 at 12:35
  • @SamuelLebron It wouldn't matter even if you have JREs set up within Eclipse. Those settings will not influence the startup of Eclipse itself in any way. – Marko Topolnik Aug 28 '13 at 12:50
  • Then isn't this a more general question? How does any application that requires Java find the installed JRE? Such as your web browser?? – Keith Madsen Aug 28 '13 at 12:50
  • 1
    No, it isn't. There are different ways of resolving the JRE location. One is system path; another is `JAVA_HOME`; and you mentioned a third, unrelated mechanism, used by browsers. Eclipse uses only one of these mechanisms, which is the system path. – Marko Topolnik Aug 28 '13 at 12:51
  • @MarkoTopolnik We can run eclipse with JDK by giving -vm in eclipse.ini file. Why would anyone want to run in JDK not with JRE? Could you please explain? – MaheshVarma Aug 28 '13 at 12:54
  • @MarkoTopolnik "system path" means the PATH environment variable? – MaheshVarma Aug 28 '13 at 12:56
  • I didn't mention a third mechanism, I referred to the standard process used by various applications (i.e. eclipse, browsers) to find the latest installed version of JRE. As already pointed out above by yourself, it's determined by executing `system32\java.exe`. – Keith Madsen Aug 28 '13 at 13:05
  • @MarkoTopolnik I don't have java.exe in my system32 directory. – MaheshVarma Aug 28 '13 at 13:14
  • @SamuelLebron Yes, it means the PATH variable – Marko Topolnik Aug 28 '13 at 13:15
  • @SamuelLebron That surprises me... check also the `windows` directory itself. My Windows XP definitely has `java.exe` in `System32`. – Marko Topolnik Aug 28 '13 at 13:16
  • @KeithMadsen `sytem32\java.exe` is executed by Eclipse only if it's the first one to be found on the system path. The JRE used by browsers cannot be chosen by changing the system path. – Marko Topolnik Aug 28 '13 at 13:22
  • 1
    @SamuelLebron About why use JDK and not JRE, JDK is just a superset of JRE, so why not? Many developers don't even install a separate JRE, they use one JDK installation. – Marko Topolnik Aug 28 '13 at 13:24
  • @MarkoTopolnik My actual doubt is in what case we configure -vm path to jdk ? in eclipse.ini file? And I am sure there is no java.exe in System32 directory – MaheshVarma Aug 28 '13 at 13:36
  • Normally you'd want to do that if, for some quite specific reason, you are not satisfied with using the system-wide default JDK to run Eclipse. – Marko Topolnik Aug 28 '13 at 14:22