Running Eclipse-CDT on Ubuntu 18.04 causes java.lang.ClassNotFoundException

柔情痞子 提交于 2020-02-24 12:01:28

问题


I am running a Virtual Machine of Ubuntu 18.04 via Oracle VirtualBox. I need Eclipse (including cdt) for a c++ project. So I ran the following statement on the console:

sudo apt-get install eclipse eclipse-cdt g++

Then I waited until it finished installing. Afterwards, I tried to run Eclipse, which caused the following error:

An error has occurred. See the log file /home/matthias/.eclipse/org.eclipse.platform_3.8_155965261/configuration/1540208856928.log

So, I checked the log file. It says the following:

!SESSION Mon Oct 22 13:38:43 CEST 2018 ----------------------------------------- !ENTRY org.eclipse.equinox.launcher 4 0 2018-10-22 13:38:43.262 !MESSAGE Exception launching the Eclipse Platform: !STACK java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:626) 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)

Unfortunately, I am an absolute beginner with Ubuntu, as well as c++. I have no idea what could cause this problem. Can anybody help me?


回答1:


I found that on Ubuntu18.04 this is due to a packaging problem (debugged with the help of a talented coworker). The fix was to manually install files from the older libequinox-osgi-java_3.8.1-8 package, to keep packaging happy.

  1. Locate and get the .deb file
  2. Examine contents of package vs. the system for overlaps
  3. Manually extract deb into '/'

Commands:

$ cd /tmp
$ wget http://archive.ubuntu.com/ubuntu/pool/universe/e/eclipse/libequinox-osgi-java_3.8.1-8_all.deb

$ dpkg -c /tmp/libequinox-osgi-java_3.8.1-8_all.deb
$ dpkg -L libequinox-osgi-java

$ cd /
$ sudo dpkg -x /tmp/libequinox-osgi-java_3.8.1-8_all.deb

Notes:

Here we see commands to show eclipse depends on eclipse-rcp, which depends on libequinox-osgi-java (>= 3.9.1), which are all installed:

$ lsb_release -rc
Release:        18.04
Codename:       bionic

$ apt-rdepends eclipse 2>&1 | egrep '^eclipse-rcp|libequinox-osgi-java'
eclipse-rcp
  Depends: libequinox-osgi-java (>= 3.9.1)
libequinox-osgi-java

$ dpkg-query -W eclipse eclipse-rcp libequinox-osgi-java
eclipse 3.8.1-11
eclipse-rcp     3.8.1-11
libequinox-osgi-java    3.9.1-1

These commands show that the out-of-the box eclipse stubbornly insists on loading the older osgi_3.8.1.dist.jar despite not being able to stat it or open it:

$ strace -f -e trace=file /usr/lib/eclipse/eclipse -debug -clean -initialize 2>&1 |
    egrep '^Framework.located|file:.*osgi_3.*jar|stat.*osgi_3.*jar'
[pid 117096] stat("/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar", 0x7f4f0ca95540) = -1 ENOENT (No such file or directory)
[pid 117096] stat("/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar", 0x7f4f0ca954c0) = -1 ENOENT (No such file or directory)
[pid 117096] stat("/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar", 0x7f4f0ca95550) = -1 ENOENT (No such file or directory)
[pid 117096] stat("/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar", 0x7f4f0ca954d0) = -1 ENOENT (No such file or directory)
Framework located:
    file:/usr/lib/eclipse/plugins/org.eclipse.osgi_3.8.1.dist.jar
...

The older package just happens to be the same package used in the Ubuntu16.04 eclipse packages. We tried a few different ways to force install both older and newer packages, etc. but this made packaging unhappy and the manual extract Just Worked(tm).



来源:https://stackoverflow.com/questions/52928735/running-eclipse-cdt-on-ubuntu-18-04-causes-java-lang-classnotfoundexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!