eclipse 霓虹灯:如何在 jdk9 上运行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34947994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Neon: how to run on jdk9?
提问by kleopatra
Just started playing with jdk9 - and kind-of stuck right at the beginning:
刚开始玩 jdk9 - 一开始就卡住了:
- 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)
- 下载并解压 eclipse-java-neon-m4a-win32
- 安装了 java 9 支持(来自市场的 dnd )
- 下载并安装jdk9u99(只有jdk,不是公共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.
此时,我可以使用 jre/jdk(在 eclipse.ini 中使用/out vm 参数)并使用 java 9 支持在我的默认 java(即 8u60)上运行 eclipse。
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).
下一步,我想用 java 9 运行 eclipse:将 vm-arg 添加到 eclipse.ini,现在 eclipse 中止其启动并显示冗长的错误日志(ini 和 log 如下所示)。
Where's the problem?
问题出在哪里?
My 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\jdk0_ea\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
The top of the error log (it's > 900k)
错误日志的顶部(> 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
最新的 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.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.
这看起来类似于错误报告中的那个。它在 M7 中被标记为固定。
回答by Pavan Kumar
Edit:You can download the latest version of eclipse which has support for Java 9 - https://www.eclipse.org/downloads/eclipse-packages/
编辑:您可以下载支持 Java 9 的最新版本 eclipse - 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
我正在运行 Java(TM) SE Runtime Environment (build 9-ea+158) 和 eclipse 版本: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.
不知何故,带有-Djdk.launcher.addmods=
和-addmods
使用值的解决方案java.se.ee
或java.annotations.common
不起作用。
Below is the solution that worked for me:
以下是对我有用的解决方案:
--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
回答by Kondal Kolipaka
Whoever is facing the same Eclipse crash issue with the Java 11, none of the above solutions seem to work.
无论谁在 Java 11 中遇到相同的 Eclipse 崩溃问题,上述解决方案似乎都不起作用。
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.
如此处https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390 所述,此问题已通过 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
这是提到的解决方法https://bugs.eclipse.org/bugs/show_bug.cgi?id=533390#c22。然而,这只是一个短期的解决方法,所以最好将 eclipse 更新到 4.8
Steps:
脚步:
- Go to eclipse config.ini file, which you find here /Applications/Eclipse_4.7.2 .app/Contents/Eclipse/configuration/config.ini
- Add the below content
- 转到 eclipse config.ini 文件,您可以在此处找到该文件 /Applications/Eclipse_4.7.2 .app/Contents/Eclipse/configuration/config.ini
- 添加以下内容
.
.
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
回答by Klara
To get rid of the java.lang.ClassNotFoundException: javax.annotation.PostConstruct
issue, try adding the following line under -vmargs
in your eclipse.ini
:
要解决此java.lang.ClassNotFoundException: javax.annotation.PostConstruct
问题,请尝试-vmargs
在您的下添加以下行eclipse.ini
:
-Djdk.launcher.addmods=java.annotations.common
(Will change to --add-modules=java.annotations.common
in JDK 9 EA build 132)
(将--add-modules=java.annotations.common
在 JDK 9 EA build 132 中更改为)
See https://bugs.eclipse.org/bugs/show_bug.cgi?id=493761
见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
更新:由于这个答案,更多的事情发生了变化,我目前正在使用 JDK 9 b177 运行 Eclipse,并添加了这些 vmargs:--add-modules=java.xml.bind,java.xml.ws.annotation
回答by Pratik Patil
Add the following line at the end of eclipse.ini
在 eclipse.ini 的末尾添加以下行
--add-modules=java.se.ee
回答by Naman
Eclipse Oxygen.1a (4.7.1a) Release
Eclipse Oxygen.1a (4.7.1a) 发布
Since a lot of Q&A's have been marked duplicate of this and the already suggested solutions are nevertheless hacky.
由于许多问答已被标记为重复,并且已经建议的解决方案仍然是hacky。
Update as of 11 October,2017- You shall upgrade to the latest eclipse packageEclipse Oxygen.1a (4.7.1a) which is marked as released and supports Java 9.
2017年10 月 11 日更新- 您应升级到最新的Eclipse 包Eclipse Oxygen.1a (4.7.1a),它被标记为已发布并支持 Java 9。
回答by sodhankit
I have the same error I find solution from Configure Eclipse for Java 9
我有同样的错误,我从Configure Eclipse for Java 9找到解决方案
Following edit you have to do in eclipse.ini file
以下编辑您必须在 eclipse.ini 文件中进行
- -vm C:\Program Files\Java\jdk-9\bin\javaw.exe
- --add-modules=ALL-SYSTEM
- -vm C:\Program Files\Java\jdk-9\bin\javaw.exe
- --add-modules=ALL-SYSTEM
And It will solve your problem. Your eclipse.ini file look like following:
它会解决你的问题。您的 eclipse.ini 文件如下所示:
--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM
回答by E-Riz
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 pagefor details (and pay careful attention to the details written there).
您eclipse.ini
指定 JVM 是错误的。首先,-vm
选项需要靠近结尾,就在任何-vmargs
一行之前。其次,您不指定bin
文件夹的位置,而是指定 java 可执行文件(或 dll)。有关详细信息,请参阅eclipse.ini wiki 页面(并注意那里写的详细信息)。
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.
顺便说一句,你从哪里得到信息来写eclipse.ini
你的方式?我想知道消息来源,希望能纠正错误信息。
回答by filip_j
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
我遇到过同样的问题。当您选择使用 Java 9 JDK 构建/编译项目时,将显示 NoClassDefFoundError。Eclipse 无法在根 JDK 文件夹中找到所需的 jar 文件,因此无法完全启动。从市场安装 Java 9 支持插件后,您也许可以启动 Eclipse,但仍然会看到很多错误并且无法编译单个项目。解决方案(目前)是在“项目首选项”下的“已安装的 JRE”中切换到 Java 9 JRE。这为我解决了一切问题
Taken from here, you may want to read the full article for more instructions
取自此处,您可能需要阅读全文以获取更多说明
回答by SHASHI SHEKHAR Barnwal
Adding this in eclipse.ini worked for me
在 eclipse.ini 中添加这个对我有用
--add-modules=java.se.ee
-XX:+IgnoreUnrecognizedVMOptions
回答by Developersh
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.
这个问题有时是由于机器中的 java 版本不同。我解决了这个问题以使用正确的版本更新 .ini 文件。以下配置对我有用。
- 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
- 启动
插件/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar - vm
C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe - 虚拟机
- Dosgi.requiredJavaVersion=1.8
- Xmx2G
- Xms200米
- XX:MaxPermSize=512m