I'm running Eclipse Oxygen (1A) on my Mac and I can see in the "Installation Details" that the JVM currently being used by the IDE itself (to actually launch the JVM) is Oracle's 1.8.0_131
JVM. I have a few other JVMs installed including the latest release 1.8.0_161
and I'd like to switch to the latest.
Just to be clear: I'm not trying to set the execution environment which is used when compiling and/or launching code for a particular project. I'm trying to change the JVM which is used when launching Eclipse itself.
So far, I've made sure that Eclipse is aware of my updated JRE and that it is indeed the default "Installed JRE", but restarting Eclipse ends up using the same, old, JVM (1.8.0_131).
Is there a way to tell Eclipse that I'd like to use an updated JVM without editing the Eclipse launch scripts directly? (I'm assuming I could do that if I wanted to, but I'd prefer not to do so.)
-- Go to the Eclipse Window > preferences, in "Java > Installed JREs". -- Copy the current default JRE with a new name, for example myJRE. -- Select the new JRE and click on the "Edit" button. -- In the "Edit JRE" dialog, add your JVM arguments in the "Default VM Arguments" field.
In the reference documentation we learn (basic) details on how the Eclipse launcher executable looks for suitable Java installations:
-vm
(Executable, Main)when passed to the Eclipse executable, this option is used to locate the Java VM to use to run Eclipse. It should be the full file system path to an appropriate: Java
jre/bin
directory, Java Executable, Java shared library (jvm.dll or libjvm.so), or a Java VM Execution Environment description file.If not specified, the Eclipse executable uses a search algorithm to locate a suitable VM. In any event, the executable then passes the path to the actual VM used to Java Main using the -vm argument. Java Main then stores this value in eclipse.vm.
Sadly, the result of that "search algorithm" is not explicitly specified which somehow makes it "a bit" non-deterministic. Even more complicating: It might be a strategy which is platform dependent.
EDIT: In the section Eclipse Launcher the algorithm is explained better, providing more details.
When no
-vm
is specified, the launcher looks for a virtual machine first in a jre directory in the root of eclipse and then on the search path.
Given the above "jvm search" process and (the related) implications, you can (only) have a stable environment by specifying a path via -vm
in eclipse.ini
. This should point to the "stable" path as returned by the command /usr/libexec/java_home -v 1.8
*.
*Note: Simply, check the result of this command via a Terminal locally.
In my MacOS environment the above command results in:
/Library/Java/JavaVirtualMachines/1.8.0.jdk/Contents/Home
As you can see in the next listing, I created a symlink which points to the actual and up2date JDK as installed on in my system.
node:JavaVirtualMachines user$ ls -lah
total 0
drwxr-xr-x 6 root wheel 192B 18 Jan 13:35 .
drwxr-xr-x 5 root wheel 160B 6 Okt 14:28 ..
lrwxr-xr-x 1 root wheel 17B 18 Jan 13:34 1.8.0.jdk -> jdk1.8.0_161.jdk/
lrwxr-xr-x 1 root wheel 14B 3 Nov 10:42 1.9.0.jdk -> jdk-9.0.1.jdk/
drwxr-xr-x 3 root wheel 96B 3 Nov 10:40 jdk-9.0.1.jdk
drwxr-xr-x 3 root wheel 96B 18 Jan 13:32 jdk1.8.0_161.jdk
Investigating your question further, I came along with an interesting observation in my local Eclipse Oxygen.2 installation which might also apply in your case. In the below screenshot we see, that the JRE name is somehow "static" and not updated with new versions.
Verify your local situation by clicking the "Edit..." button in the Installed JRE list. It might actually point to an up2date JRE/JDK version. In the best case you just have to adjust the name of this entry.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With