我有Xubuntu 17.10。我尝试通过 apt-get 安装 Eclipse。当我尝试运行它时,出现错误
An error has occurred. See the log file
/home/jaakko/.eclipse/org.eclipse.platform_3.8_155965261/configuration/1510564798671.log.
日志文件如下:
!SESSION 2017-11-13 11:19:57.077 -----------------------------------------------
eclipse.buildId=debbuild
java.version=9.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments: -os linux -ws gtk -arch x86_64
!ENTRY org.eclipse.equinox.simpleconfigurator 4 0 2017-11-13 11:20:00.209
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: The bundle "org.eclipse.equinox.simpleconfigurator_1.0.301.dist [1]" could not be resolved. Reason: Missing Constraint: Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,J2SE-1.4
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1332)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1316)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:323)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.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.osgi 4 0 2017-11-13 11:20:00.222
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.simpleconfigurator_1.0.301.dist.jar was not resolved.
!ENTRY org.eclipse.osgi 2 0 2017-11-13 11:20:00.256
!MESSAGE One or more bundles are not resolved because the following root constraints are not resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2017-11-13 11:20:00.256
!MESSAGE Bundle initial@reference:file:plugins/org.eclipse.equinox.simpleconfigurator_1.0.301.dist.jar was not resolved.
!SUBENTRY 2 org.eclipse.equinox.simpleconfigurator 2 0 2017-11-13 11:20:00.256
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
!ENTRY org.eclipse.osgi 2 0 2017-11-13 11:20:00.268
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2017-11-13 11:20:00.268
!MESSAGE Bundle org.eclipse.equinox.simpleconfigurator_1.0.301.dist [1] was not resolved.
!SUBENTRY 2 org.eclipse.equinox.simpleconfigurator 2 0 2017-11-13 11:20:00.268
!MESSAGE Missing required capability Require-Capability: osgi.ee; filter="(|(&(osgi.ee=CDC/Foundation)(version=1.1))(&(osgi.ee=JavaSE)(version=1.4)))".
!ENTRY org.eclipse.osgi 4 0 2017-11-13 11:20:00.281
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
我发现如果我使用 Java 9 会出现此问题,但如果我使用 Java 8 则不会。
如何将 Eclipse 安装到我的计算机上以运行 Java 9?
Ubuntu 18.04 及更高版本
默认 Ubuntu 存储库中的 Eclipse snap 包非常适合 Java 编程,因为它与 Java 开发环境捆绑在一起。要安装它,请打开终端并输入:
此命令将安装最新的 Photon Release 4.8 版本的 Eclipse IDE for Java Developers,该版本已在 8 天前更新。Eclipse 更改了其代号政策,以便 2018 年 9 月及以后的 Eclipse 版本以发布日期的年份和月份命名,例如 Eclipse 2020-06。此命名方案也适用于 eclipse snap 包。
Eclipse Photon JDT 完全支持 Java 9:
注意: 要在 18.04 及更高版本中向 Eclipse 添加新的 Java 版本,例如 openjdk-11-jdk,请按照上面步骤 1-9 中列出的说明进行操作,只需将字符串替换为
java-9-openjdk
您要添加到的 Java 版本已安装 JRE。Ubuntu 17.10
我已经安装了 Eclipse Oxygen(最新版本的 Eclipse)和 openjdk-9-jdk,Eclipse 在这个版本中使用了 openjdk-9-jdk。如果您想将 openjdk-8-jdk 保留为默认 Java 版本以在新的 Eclipse Oxygen 中使用,您可以打开 Eclipse 并从 Eclipse 内部添加 openjdk-9-jdk,如下所示。
选择窗口->首选项
在 Preferences 窗口右侧的窗格中,单击Java左侧的黑色三角形将其展开。
双击已安装的 JRE。
单击首选项窗口左侧的添加以添加新的 JRE。
选择标准 VM并单击下一步。
在 JRE 主页中:字段类型
/usr/lib/jvm/java-9-openjdk-amd64
(或 i386 而不是 amd64 用于 32 位 Eclipse)在 JRE 名称中:字段类型
java-9-openjdk-amd64
(或 i386 而不是 amd64 用于 32 位 Eclipse)单击应用按钮。
现在在步骤 3 中的已安装 JRE中。您可以单击已安装 JRE 列表中 JRE 左侧的复选框以将其选为默认值,然后单击应用按钮以将更改应用到默认已安装 JRE 中。
相同的说明不适用于 Ubuntu 16.04 中的默认 Eclipse 版本。
您必须安装
openjdk-8-jre
:接下来切换到 jre-8 版本:
检查java版本:
开始日食