Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse uses wrong java home

I'm using Eclipse on Windows and I don't understand why it's using a specific java version. I can check the java version using by Eclipse doing this Help -> About Eclipse -> Installation Details -> Configuration. The java.home is set to C:\Program Files\Java\jre1.8.0_65. But my environment variables are configured like this :

  • JAVA_7_HOME : C:\java\jdk1.7.0_79
  • JAVA_8_HOME : C:\java\jdk1.8.0_60
  • JAVA_HOME : %JAVA_8_HOME%
  • PATH : ...;%JAVA_HOME%\bin;...;

Why Eclipse is not using C:\java\jdk1.8.0_60 as java.home.

like image 844
cheb1k4 Avatar asked Dec 11 '22 20:12

cheb1k4


1 Answers

The JAVA_HOME environment variable is not supposed to be the same the java.home system property. JAVA_HOME is an OS-level environment setting, while java.home is a Java-level property that's established by the JVM when it starts; it indicates the root (home) of the JRE that is currently running (which very well might be different than where you pointed JAVA_HOME to).

The reason you're not getting the value for java.home that you expect is probably because you have not specified to Eclipse what JVM you want it to run in (which is separate from the Installed JREs you see in the Preferences). Follow the instructions for specifying the JVM in eclipse.ini, point it to the JDK location you want (C:\java\jdk1.8.0_60 according to your example above), then Eclipse will report that as the value of java.home (since that will be the JVM that's running Eclipse itself).

like image 195
E-Riz Avatar answered Dec 25 '22 23:12

E-Riz