Sometime, your default Java machine and your Eclipse IDE couldn’t run using same Java version. For example, your default Java machine is Java 9 but the latest Eclipse IDE can only run on Java 8. So, how can we deal with this situation? In this tutorial, I will guide you how to specify Java version for your Eclipse.
To run the Eclipse IDE with specify Java version, we need open and modify the eclipse.ini file in Eclipse home folder.
For example, I am using Eclipse Oxygen (4.7) on macOS and installed both Java 8 and Java 9 but default Java version is Java 9. When I ran this Eclipse version, I received the error message like below:
That is cause the Eclipse Oxygen cannot run on Java 9.
To resolve this problem, let open your eclipse.ini file in Eclipse home folder. For me, it located at /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini.
The content of this file, something like below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
-startup ../Eclipse/plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar --launcher.library ../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.500.v20170531-1133 -product org.eclipse.epp.package.jee.product -showsplash org.eclipse.epp.package.common --launcher.defaultAction openFile --launcher.defaultAction openFile --launcher.appendVmargs -vmargs -Dosgi.requiredJavaVersion=1.8 -Dosgi.instance.area.default=@user.home/eclipse-workspace -XX:+UseG1GC -XX:+UseStringDeduplication -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Dosgi.requiredJavaVersion=1.8 -Xms256m -Xmx1024m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts |
To let the Eclipse IDE run on Java 8, we need add more argument as below before the line “-vmargs” in this eclipse.ini file.
1 2 |
-vm <Path_of_Java_8_installation_folder>/bin |
For my example:
1 2 |
-vm /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/ |
Now, your Eclipse can start without any problems.