Neon: how to run on jdk9?
Asked Answered
C

11

20

Just started playing with jdk9 - and kind-of stuck right at the beginning:

  • downloaded and extracted eclipse-java-neon-m4a-win32
  • installed java 9 support (by dnd from marketplace)
  • downloaded and installed jdk9u99 (only the jdk, not the public jre)

At this point, I can run eclipse on my default java (which is 8u60) both with jre/jdk (with/out vm argument in eclipse.ini) and use the java 9 support.

As next step, I wanted to run eclipse with java 9: added the vm-arg to eclipse.ini, now eclipse aborts its startup with a lengthy error log (both ini and log are shown below).

Where's the problem?

My ini:

-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20151021-1308.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.300.v20151013-1129
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
d:\java\jdk\190_ea\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m

The top of the error log (it's > 900k)

!SESSION 2016-01-22 14:31:55.974 -----------------------------------------------
eclipse.buildId=4.6.0.I20151209-2300
java.version=9-ea
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.equinox.common 4 0 2016-01-22 14:31:57.113
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.equinox.common [143]
  Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))"

    at org.eclipse.osgi.container.Module.start(Module.java:429)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

!ENTRY org.eclipse.ant.core 4 0 2016-01-22 14:31:57.175
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.ant.core [61]
  Unresolved requirement: Require-Bundle: org.eclipse.core.variables; bundle-version="[3.1.0,4.0.0)"
    -> Bundle-SymbolicName: org.eclipse.core.variables; bundle-version="3.2.800.v20130819-1716"; singleton:="true"
       org.eclipse.core.variables [88]
         Unresolved requirement: Require-Bundle: org.eclipse.core.runtime; bundle-version="[3.3.0,4.0.0)"
           -> Bundle-SymbolicName: org.eclipse.core.runtime; bundle-version="3.12.0.v20151104-0048"; singleton:="true"
              org.eclipse.core.runtime [87]
                Unresolved requirement: Require-Bundle: org.eclipse.equinox.common; bundle-version="[3.8.0,4.0.0)"; visibility:="reexport"
                  -> Bundle-SymbolicName: org.eclipse.equinox.common; bundle-version="3.8.0.v20151023-1114"; singleton:="true"
                     org.eclipse.equinox.common [143]
                       Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))"

    at org.eclipse.osgi.container.Module.start(Module.java:429)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1561)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

Update

still no luck with the latest Neon (M6) and 9-ea-113, the logged error has changed, though

!SESSION 2016-04-28 16:27:53.344 -----------------------------------------------
eclipse.buildId=4.6.0.I20160317-0200
java.version=9-ea
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.osgi 4 0 2016-04-28 16:28:10.145
!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.createDefaultHeadlessContext(E4Application.java:490)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:504)
    at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:203)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:627)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:605)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:520)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:670)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:609)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1516)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1489)
Caused by: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct
    at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:151)
    at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:375)
    ... 23 more

Which looks similar to the one in a bug report. It's marked as fixed in M7.

Cusk answered 22/1, 2016 at 13:36 Comment(9)
Should work with download.eclipse.org/eclipse/downloads/drops4/Y20160324-1000Kilian
@Kilian thanks, will try soonCusk
What do you mean by "only the jdk, not the public jre", did you mix the java 9 jdk and java 7/8 jre? That would sound like something that might cause java.lang.NoClassDefFoundErrorStatfarad
@Statfarad yeah sure I mix, won't have a preview as public standard jre :-) But they should be isolated, I think (and always were in earlier versions)Cusk
I do not know how you mix it, but javax/annotation/PostConstruct is in rt.jar, and in jdk 9 there is not such a file.Statfarad
here they say you need to start neon with -addmods java.se.eeStatfarad
@Statfarad will have a look thanks!Cusk
i just had the same problem. adding -addmods java.se.ee on 2 lines at the end of the .ini file does not work. i get the same: NoClassDefFoundError: javax/annotation/PostConstruct error.Atheistic
After "Xmx", you should add "--add-modules=ALL-SYSTEM" in "eclipse.ini" according to bugs.eclipse.org/bugs/show_bug.cgi?id=493761#c83Curch
C
30

Edit: You can download the latest version of eclipse which has support for Java 9 - https://www.eclipse.org/downloads/eclipse-packages/


I am running Java(TM) SE Runtime Environment (build 9-ea+158) and eclipse Version: Neon.2 Release (4.6.2) - Build id: 20161208-0600

Somehow the solutions with -Djdk.launcher.addmods= and -addmods using values java.se.ee or java.annotations.common did not work.

Below is the solution that worked for me:

--add-modules=java.se.ee

Source: https://issues.jboss.org/browse/JBIDE-22417?focusedCommentId=13310535&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13310535

Churinga answered 28/2, 2017 at 9:35 Comment(1)
For RED ide, I added this line to /opt/RED/RED.ini fileFeces
S
19

Whoever is facing the same Eclipse crash issue with the Java 11, none of the above solutions seem to work.

Here is the error:

org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct

As mentioned here https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390, this issue is fixed with the Eclipse Photon 4.8.

Here is the workaround mentioned https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390#c22. However, this just a short-term workaround so it's better to update the eclipse to 4.8

Steps:

  1. Go to eclipse config.ini file, which you find here /Applications/Eclipse_4.7.2 .app/Contents/Eclipse/configuration/config.ini
  2. Add the below content

.

org.osgi.framework.system.packages = \
 javax.accessibility,\
 javax.activation,\
 javax.activity,\
 javax.crypto,\
 javax.crypto.interfaces,\
 javax.crypto.spec,\
 javax.imageio,\
 javax.imageio.event,\
 javax.imageio.metadata,\
 javax.imageio.plugins.bmp,\
 javax.imageio.plugins.jpeg,\
 javax.imageio.spi,\
 javax.imageio.stream,\
 javax.jws,\
 javax.jws.soap,\
 javax.lang.model,\
 javax.lang.model.element,\
 javax.lang.model.type,\
 javax.lang.model.util,\
 javax.management,\
 javax.management.loading,\
 javax.management.modelmbean,\
 javax.management.monitor,\
 javax.management.openmbean,\
 javax.management.relation,\
 javax.management.remote,\
 javax.management.remote.rmi,\
 javax.management.timer,\
 javax.naming,\
 javax.naming.directory,\
 javax.naming.event,\
 javax.naming.ldap,\
 javax.naming.spi,\
 javax.net,\
 javax.net.ssl,\
 javax.print,\
 javax.print.attribute,\
 javax.print.attribute.standard,\
 javax.print.event,\
 javax.rmi,\
 javax.rmi.CORBA,\
 javax.rmi.ssl,\
 javax.script,\
 javax.security.auth,\
 javax.security.auth.callback,\
 javax.security.auth.kerberos,\
 javax.security.auth.login,\
 javax.security.auth.spi,\
 javax.security.auth.x500,\
 javax.security.cert,\
 javax.security.sasl,\
 javax.sound.midi,\
 javax.sound.midi.spi,\
 javax.sound.sampled,\
 javax.sound.sampled.spi,\
 javax.sql,\
 javax.sql.rowset,\
 javax.sql.rowset.serial,\
 javax.sql.rowset.spi,\
 javax.swing,\
 javax.swing.border,\
 javax.swing.colorchooser,\
 javax.swing.event,\
 javax.swing.filechooser,\
 javax.swing.plaf,\
 javax.swing.plaf.basic,\
 javax.swing.plaf.metal,\
 javax.swing.plaf.multi,\
 javax.swing.plaf.nimbus,\
 javax.swing.plaf.synth,\
 javax.swing.table,\
 javax.swing.text,\
 javax.swing.text.html,\
 javax.swing.text.html.parser,\
 javax.swing.text.rtf,\
 javax.swing.tree,\
 javax.swing.undo,\
 javax.tools,\
 javax.xml,\
 javax.xml.bind,\
 javax.xml.bind.annotation,\
 javax.xml.bind.annotation.adapters,\
 javax.xml.bind.attachment,\
 javax.xml.bind.helpers,\
 javax.xml.bind.util,\
 javax.xml.crypto,\
 javax.xml.crypto.dom,\
 javax.xml.crypto.dsig,\
 javax.xml.crypto.dsig.dom,\
 javax.xml.crypto.dsig.keyinfo,\
 javax.xml.crypto.dsig.spec,\
 javax.xml.datatype,\
 javax.xml.namespace,\
 javax.xml.parsers,\
 javax.xml.soap,\
 javax.xml.stream,\
 javax.xml.stream.events,\
 javax.xml.stream.util,\
 javax.xml.transform,\
 javax.xml.transform.dom,\
 javax.xml.transform.sax,\
 javax.xml.transform.stax,\
 javax.xml.transform.stream,\
 javax.xml.validation,\
 javax.xml.ws,\
 javax.xml.ws.handler,\
 javax.xml.ws.handler.soap,\
 javax.xml.ws.http,\
 javax.xml.ws.soap,\
 javax.xml.ws.spi,\
 javax.xml.ws.spi.http,\
 javax.xml.ws.wsaddressing,\
 javax.xml.xpath,\
 org.ietf.jgss,\
 org.omg.CORBA,\
 org.omg.CORBA_2_3,\
 org.omg.CORBA_2_3.portable,\
 org.omg.CORBA.DynAnyPackage,\
 org.omg.CORBA.ORBPackage,\
 org.omg.CORBA.portable,\
 org.omg.CORBA.TypeCodePackage,\
 org.omg.CosNaming,\
 org.omg.CosNaming.NamingContextExtPackage,\
 org.omg.CosNaming.NamingContextPackage,\
 org.omg.Dynamic,\
 org.omg.DynamicAny,\
 org.omg.DynamicAny.DynAnyFactoryPackage,\
 org.omg.DynamicAny.DynAnyPackage,\
 org.omg.IOP,\
 org.omg.IOP.CodecFactoryPackage,\
 org.omg.IOP.CodecPackage,\
 org.omg.Messaging,\
 org.omg.PortableInterceptor,\
 org.omg.PortableInterceptor.ORBInitInfoPackage,\
 org.omg.PortableServer,\
 org.omg.PortableServer.CurrentPackage,\
 org.omg.PortableServer.POAManagerPackage,\
 org.omg.PortableServer.POAPackage,\
 org.omg.PortableServer.portable,\
 org.omg.PortableServer.ServantLocatorPackage,\
 org.omg.SendingContext,\
 org.omg.stub.java.rmi,\
 org.w3c.dom,\
 org.w3c.dom.bootstrap,\
 org.w3c.dom.css,\
 org.w3c.dom.events,\
 org.w3c.dom.html,\
 org.w3c.dom.ls,\
 org.w3c.dom.ranges,\
 org.w3c.dom.stylesheets,\
 org.w3c.dom.traversal,\
 org.w3c.dom.views,\
 org.w3c.dom.xpath,\
 org.xml.sax,\
 org.xml.sax.ext,\
 org.xml.sax.helpers
Steradian answered 28/9, 2018 at 9:50 Comment(3)
Works like a charm for DBever!Rhombohedral
Thanks for the details. Short term solution but saves time.Blabber
This worked although Eclipse takes about 5 minutes to start up now.Ecotone
A
11

To get rid of the java.lang.ClassNotFoundException: javax.annotation.PostConstruct issue, try adding the following line under -vmargs in your eclipse.ini:

-Djdk.launcher.addmods=java.annotations.common

(Will change to --add-modules=java.annotations.common in JDK 9 EA build 132)

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=493761

UPDATE: Since this answer, more things changed, I am currently running Eclipse with JDK 9 b177 and these added vmargs: --add-modules=java.xml.bind,java.xml.ws.annotation

Anatolio answered 16/8, 2016 at 10:10 Comment(2)
This solution seems not to work on newer builds (build 9+176). However, Pavan Kumar's answer works properly.Fannie
--add-modules=java.xml.bind,java.xml.ws.annotation worked for me.Rus
C
5

Add the following line at the end of eclipse.ini

--add-modules=java.se.ee
Carmelocarmen answered 15/1, 2018 at 9:47 Comment(1)
please mention the Eclipse version because it is not working with Eclipse Oxygen 3a 2018Sumatra
P
3

Eclipse Oxygen.1a (4.7.1a) Release

Since a lot of Q&A's have been marked duplicate of this and the already suggested solutions are nevertheless hacky.

Update as of 11 October,2017 - You shall upgrade to the latest eclipse package Eclipse Oxygen.1a (4.7.1a) which is marked as released and supports Java 9.

Philbert answered 12/10, 2017 at 3:31 Comment(0)
Z
1

Your eclipse.ini is wrong for specifying the JVM. First of all, the -vm option needs to be near the end, right before any -vmargs line. Second, you don't specify the location of the bin folder, rather the java executable (or dll). See the eclipse.ini wiki page for details (and pay careful attention to the details written there).

By the way, where did you get the info to write eclipse.ini the way you did? I'd like to know the source in hopes of correcting that misinformation.

Zeppelin answered 22/1, 2016 at 15:22 Comment(2)
thanks - guilty of incorrectly copying from waynebeaton.wordpress.com/2015/10/18/… (that's Linux, so might make a difference to my win7 <g> Now changed the ini as suggested - error is unchanged.Cusk
Bummer, I was hoping (grasping, really) that the other errors were due to not finding the Java 9 VM. Dirk is probably more on track in suspecting the EE resolution is somehow related.Zeppelin
K
1

I have the same error I find solution from Configure Eclipse for Java 9

Following edit you have to do in eclipse.ini file

  1. -vm C:\Program Files\Java\jdk-9\bin\javaw.exe
  2. --add-modules=ALL-SYSTEM

And It will solve your problem. Your eclipse.ini file look like following:

--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
Kaneshakang answered 12/12, 2017 at 3:29 Comment(0)
T
0

I had the same issue. The NoClassDefFoundError shows when you select to build/compile your project with Java 9 JDK. Eclipse is unable to find a required jar file in root JDK folder, so it fails to start completely. After installing the Java 9 support plugin from the marketplace you may be able to start Eclipse, but still you will see a lot of errors and won't be able to compile a single project. The solution (for now) is to switch to Java 9 JRE in "Installed JREs" under "Project Preferences". This fixed everything for me

Taken from here, you may want to read the full article for more instructions

Totter answered 12/9, 2017 at 18:4 Comment(0)
U
0

Adding this in eclipse.ini worked for me

--add-modules=java.se.ee   
-XX:+IgnoreUnrecognizedVMOptions 
Union answered 22/12, 2018 at 18:8 Comment(0)
L
0

This issue sometimes due to having a different version of java in the machine. I solved this issue to update the .ini file with the correct version. Below configuration is working for me.

  • startup
    plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
  • vm
    C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe
  • vmargs
  • Dosgi.requiredJavaVersion=1.8
  • Xmx2G
  • Xms200m
  • XX:MaxPermSize=512m
Lineberry answered 28/4, 2019 at 4:42 Comment(0)
T
0

I had got the same error. org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: javax/annotation/PostConstruct

Resolved it by uninstalling all different versions of java and installed just 1.8.0_231.

Worked finally.

Java 8 installation link - https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Scala IDE for Eclipse:- version - 4.7.0 http://scala-ide.org/download/sdk.html

Twilatwilight answered 23/10, 2019 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.