19

刚开始玩 jdk9 - 刚开始就卡住了:

  • 下载并解压 eclipse-java-neon-m4a-win32
  • 安装了 java 9 支持(来自市场的 dnd )
  • 下载并安装jdk9u99(只有jdk,不是公共jre)

此时,我可以使用 jre/jdk(在 eclipse.ini 中带有/out vm 参数)在我的默认 java(即 8u60)上运行 eclipse,并使用 java 9 支持。

作为下一步,我想用 java 9 运行 eclipse:将 vm-arg 添加到 eclipse.ini,现在 eclipse 用一个冗长的错误日志中止它的启动(ini 和日志都如下所示)。

问题出在哪里?

我的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

错误日志的顶部(> 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)

更新

最新的 Neon (M6) 和 9-ea-113 仍然没有运气,但记录的错误已更改

!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

这看起来类似于错误报告中的那个。它在 M7 中被标记为已修复。

4

11 回答 11

30

编辑:您可以下载支持 Java 9 的最新版本的 Eclipse - https://www.eclipse.org/downloads/eclipse-packages/


我正在运行 Java(TM) SE 运行时环境 (build 9-ea+158) 和 eclipse 版本:Neon.2 Release (4.6.2) - Build id: 20161208-0600

-Djdk.launcher.addmods=不知何故,使用和-addmods使用值的解决方案java.se.eejava.annotations.common不起作用。

以下是对我有用的解决方案:

--add-modules=java.se.ee

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

于 2017-02-28T09:35:08.183 回答
19

无论谁面临与 Java 11 相同的 Eclipse 崩溃问题,上述解决方案似乎都不起作用。

这是错误:

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

正如这里提到的https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390,Eclipse Photon 4.8 修复了这个问题。

这是提到的解决方法https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390#c22。然而,这只是一个短期的解决方法,所以最好将 eclipse 更新到 4.8

脚步:

  1. 转到 eclipse config.ini 文件,您可以在此处找到 /Applications/Eclipse_4.7.2 .app/Contents/Eclipse/configuration/config.ini
  2. 添加以下内容

.

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
于 2018-09-28T09:50:14.413 回答
11

要解决此问题,请尝试在您java.lang.ClassNotFoundException: javax.annotation.PostConstruct的下面添加以下行:-vmargseclipse.ini

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

(将--add-modules=java.annotations.common在 JDK 9 EA bu​​ild 132 中更改)

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

更新:由于这个答案,更多的事情发生了变化,我目前正在使用 JDK 9 b177 运行 Eclipse,并且这些添加了 vmargs:--add-modules=java.xml.bind,java.xml.ws.annotation

于 2016-08-16T10:10:36.900 回答
5

在 eclipse.ini 的末尾添加以下行

--add-modules=java.se.ee
于 2018-01-15T09:47:21.133 回答
3

Eclipse Oxygen.1a (4.7.1a) 发布

由于许多问答已被标记为重复,并且已经建议的解决方案仍然是hacky。

2017 年 10 月 11 日更新- 您应升级到最新的Eclipse 包Eclipse Oxygen.1a (4.7.1a),该包标记为已发布并支持 Java 9。

于 2017-10-12T03:31:39.407 回答
1

我有同样的错误,我从Configure Eclipse for Java 9 中找到了解决方案

编辑后您必须在 eclipse.ini 文件中进行

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

它会解决你的问题。您的 eclipse.ini 文件如下所示:

--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
于 2017-12-12T03:29:32.327 回答
1

eclipse.ini指定 JVM 是错误的。首先,-vm选项需要接近结尾,就在任何-vmargs一行之前。其次,您不指定bin文件夹的位置,而是指定 java 可执行文件(或 dll)。有关详细信息,请参阅eclipse.ini wiki 页面(并仔细注意那里编写的详细信息)。

顺便说一句,你从哪里得到信息来写eclipse.ini你的方式?我想知道消息来源,希望能纠正错误信息。

于 2016-01-22T15:22:50.533 回答
0

我遇到了同样的错误。org.eclipse.e4.core.di.InjectionException:java.lang.NoClassDefFoundError:javax/annotation/PostConstruct

通过卸载所有不同版本的 java 并仅安装1.8.0_231来解决它。

终于工作了。

Java 8 安装链接 - https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

用于Eclipse 的 Scala IDE :- 版本 - 4.7.0 http://scala-ide.org/download/sdk.html

于 2019-10-23T16:18:11.307 回答
0

在 eclipse.ini 中添加这个对我有用

--add-modules=java.se.ee   
-XX:+IgnoreUnrecognizedVMOptions 
于 2018-12-22T18:08:59.013 回答
0

此问题有时是由于机器中的 java 版本不同。我解决了这个问题以使用正确的版本更新 .ini 文件。以下配置对我有用。

  • 启动
    插件/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
于 2019-04-28T04:42:31.407 回答
0

我遇到过同样的问题。当您选择使用 Java 9 JDK 构建/编译项目时,会显示 NoClassDefFoundError。Eclipse 无法在 JDK 根文件夹中找到所需的 jar 文件,因此无法完全启动。从市场上安装 Java 9 支持插件后,您可能能够启动 Eclipse,但您仍然会看到很多错误并且无法编译单个项目。解决方案(目前)是在“Project Preferences”下的“Installed JREs”中切换到 Java 9 JRE。这为我解决了一切

取自这里,您可能需要阅读全文以获得更多说明

于 2017-09-12T18:04:39.447 回答