Setting Java Virtual Machine executable in Eclipse
Introduction
At some point you might end up with multiple Java versions installed on your Linux box. If you set the wrong version as the default executable certain versions of Eclipse might stop working. For example you might see the following error in your Eclipse log file (workspace/.metadata/.log):
Caused by: java.lang.ClassNotFoundException: javax.annotation.PreDestroy cannot be found by org.eclipse.e4.core.di_1.6.100.v20170421-1418
This document explains how to choose which Java executable to use with your Eclipse IDE.
Set Java VM path in Eclipse configuration file
Find file called eclipse.ini in your Eclipse installation folder (e.g. /opt/eclipse/eclipse.ini). Add those two lines:
-vm
/opt/jdk/jdk1.8/bin/java
In this example I'm using Java version 1.8 to run Eclipse Oxygen, while my default Java version is set to 1.9. Restart Eclipse after making those changes.