霓虹灯:如何在jdk9上运行?

时间:2016-01-22 13:36:36

标签: eclipse java-9 eclipse-neon

刚刚开始玩jdk9 - 并且在开头时就被卡住了:

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

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

下一步,我想用java 9运行eclipse:将vm-arg添加到eclipse.ini,现在eclipse使用冗长的错误日志中止其启动(ini和log都显示在下面)。

问题出在哪里?

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

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

更新

最新的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

看起来类似于bug report中的那个。它在M7中标记为固定。

10 个答案:

答案 0 :(得分:28)

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

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

使用值-Djdk.launcher.addmods=-addmods的{​​{1}}和java.se.ee的解决方案不起作用。

以下是适合我的解决方案:

java.annotations.common

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

答案 1 :(得分:7)

无论谁面对与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

答案 2 :(得分:4)

在eclipse.ini

的末尾添加以下行
--add-modules=java.se.ee

答案 3 :(得分:3)

Eclipse Oxygen.1a (4.7.1a) Release

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

自2017年10月11日起更新 - 您将升级到标记为已发布的最新eclipse package Eclipse Oxygen.1a(4.7.1a)并支持Java 9。

答案 4 :(得分:1)

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

顺便问一下,你在哪里得到的信息以你的方式写eclipse.ini?我想知道纠正错误信息的来源。

答案 5 :(得分:1)

我遇到同样的错误,我从Configure Eclipse for Java 9

找到解决方案

在编辑之后你必须在eclipse.ini文件

中进行
  1. -vm C:\ Program Files \ Java \ jdk-9 \ bin \ javaw.exe
  2. - 添加模块= ALL-SYSTEM
  3. 它将解决您的问题。 您的eclipse.ini文件如下所示:

    --launcher.appendVmargs
    -vm
    C:\Program Files\Java\jdk-9\bin\javaw.exe
    -vmargs
    -Dosgi.requiredJavaVersion=1.8
    --add-modules=ALL-SYSTEM
    

答案 6 :(得分:0)

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

摘自here,您可能需要阅读完整文章以获取更多说明

答案 7 :(得分:0)

在eclipse.ini中添加它对我有用

--add-modules=java.se.ee   
-XX:+IgnoreUnrecognizedVMOptions 

答案 8 :(得分:0)

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

  • 启动
    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

答案 9 :(得分: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