Tuesday, May 8, 2018

Run Eclipse Neon macOS on any Java JDK version

Starting Eclipse Neon 3 on macOS High Sierra using JDK 10 produces the following error during startup:

View Eclipse error log
$ vi ~/Documents/workspace/.metadata/.log

!SESSION 2018-05-09 08:09:01.603 -----------------------------------------------
eclipse.buildId=4.6.3.M20170301-0400
java.version=10.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product -keyring /Users/xxxx/.eclipse_keyring
Command-line arguments:  -os macosx -ws cocoa -arch x86_64 -product org.eclipse.epp.package.jee.product -keyring /Users/xxxx/.eclipse_keyring

!ENTRY org.eclipse.osgi 4 0 2018-05-09 08:09:05.117
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
        at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
        at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:294)
        at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)

        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultH

Get full path list of available Java Runtimes
$ /usr/libexec/java_home --verbose
Matching Java Virtual Machines (2):
    10.0.1, x86_64: "Java SE 10.0.1" /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
    1.8.0_172, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home


Edit eclipse .ini
$ vi /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini

Add the following to the start of the line, replace with appropriate java version
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin

No comments: