解决Linux下启动eclipse出现An error has occurred. See the log file [your workspace path]/.metadata/.log

最近在搞大数据,需要在linux下使用eclipse,第一次启动出现

An error has occurred. See the log file [your workspace path]/.metadata/.log


查看错误提到的的日志文件

!SESSION 2019-11-23 14:07:57.045 -----------------------------------------------
eclipse.buildId=4.7.0-vfinal-2017-09-29T14:34:02Z-Typesafe
java.version=11.0.4
java.vendor=Ubuntu
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.osgi 4 0 2019-11-23 14:08:26.123
!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:410)
        at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:318)
        at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultHeadlessContext(E4Application.java:491)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createDefaultContext(E4Application.java:505)
        at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:204)
        at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:614)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:594)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:151)
        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 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:566)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1499)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1472)

咦,发现java.version竟然是11.0.4,明明我配置的环境变量是openjdk-8,发现问题了,就是运行eclipse的jdk版本太高,与eclipse不兼容

查看安装eclipse路径下的[your eclipse path]/readme/readme_eclipse.html

其实里面提到了这个问题,属于挺普遍的问题

General - GCJ

GCJ is an effort by the GCC team to provide an open source Java compiler and runtime environment to interpret Java bytecode. Unfortunately, the GCJ runtime environment is not an environment that is often tested on by Eclipse developers.

The most common problems surrounding GCJ are:

    Eclipse does not start at all
    Eclipse throws a 'java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin' that can be found in the logs (located in workspace/.metadata/.log)

The workspace's log file is a good place to check to identify whether GCJ is being used or not. Every Eclipse log session is prepended with information about the runtime environment that was used to run Eclipse. The log may include something like the following: java.fullversion=GNU libgcj 4.2.1 (Debian 4.2.1-5)

If Eclipse does start, one can check which runtime environment is being used to run Eclipse by going to Help > About Eclipse SDK > Installation Details > Configuration. The About dialog itself can also provide other information, the build identifier can be of particular interest as it is tagged by some distributions. This allows the user to identify whether Eclipse was downloaded through the distribution's package management system or directly from the eclipse.org web site.
Such as:
Build id: M20070212-1330 (Ubuntu version: 3.2.2-0ubuntu3)

The two most common workarounds are:

    download the Eclipse binary from eclipse.org directly
    run Eclipse using an alternate Java runtime environment

To download Eclipse, try one of the links below:

    http://www.eclipse.org/downloads/
    http://download.eclipse.org/eclipse/downloads/

It is imperative that 64-bit builds are downloaded and used if a 64-bit Java runtime environment has been installed. Below are two sample tarball names of version 4.6 of the Eclipse SDK packaged for 32-bit and 64-bit processors.
eclipse-SDK-4.6-linux-gtk.tar.gz (32-bit)
eclipse-SDK-4.6-linux-gtk-x86_64.tar.gz (64-bit)

To run Eclipse with an alternate Java runtime environment, the path to the Java virtual machine's binary must be identified. With an Eclipse installation from the distribution, altering the $PATH variable to include the path to the alternate Java runtime environment is often not enough as the Eclipse that Linux distributions package often performs a scan internally to pick up GCJ by itself whilst ignoring what's on the $PATH. An example of the terminal's output is shown below:
searching for compatible vm...
testing /usr/lib/jvm/java-gcj...found

Once the path to the virtual machine's binary has been identified, try running Eclipse with the following command:
./eclipse -vm /path/to/jre/bin/java

For an actual example, it might look something like the following:
./eclipse -vm /usr/lib/jvm/sun-java-6/bin/java
./eclipse -vm /opt/sun-jdk-1.6.0.02/bin/java

If this seems to solve the problem, it is likely that the problem really was related to the use of GCJ as the Java runtime for running Eclipse. The eclipse.ini file located within Eclipse's folder can be altered to automatically pass this argument to Eclipse at startup. An example of its content is presented below:
-showsplash
org.eclipse.platform
-vm
/opt/sun-jdk-1.6.0.02/bin/java
-vmargs
-Xms40m
-Xmx512m

Note that every argument must be on its own line. More information about the eclipse.ini file can be found at http://wiki.eclipse.org/Eclipse.ini.

If problems persists after downloading an installation of Eclipse from eclipse.org and using a supported Java runtime environment (a list of which may be found above), you can seek further assistance through the forums, the IRC channel, and/or bugzilla. 

大致意思就是运行eclipse的jdk版本不对,有两个解决方案:

解决方案一

  1. 打开终端
  2. 进入eclipse安装目录cd ~/eclipse
  3. 以openjdk-8运行eclipse./eclipse -vm /usr/lib/jvm/java-8-openjdk-amd64/bin/java

但是下次打开eclipse还需要重新输入命令,过于麻烦

解决方案二

  1. 进入eclipse安装目录
  2. 打开eclipse.ini,写入两行
    -vm 
    /usr/lib/jvm/java-8-openjdk-amd64/bin/java
    
    如图所示

以后就可以直接打开eclipse了

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值