![通过 APT 安装的 Netbeans 打开但随后关闭,“java.lang.NoClassDefFoundError”](https://linux22.com/image/1010698/%E9%80%9A%E8%BF%87%20APT%20%E5%AE%89%E8%A3%85%E7%9A%84%20Netbeans%20%E6%89%93%E5%BC%80%E4%BD%86%E9%9A%8F%E5%90%8E%E5%85%B3%E9%97%AD%EF%BC%8C%E2%80%9Cjava.lang.NoClassDefFoundError%E2%80%9D%20.png)
我有一个全新的 Ubuntu 18.10 VM(托管在 Windows 10 上),它是从 osboxes.org 映像构建的。除了完全不相关的小东西外,我在这个原始操作系统上所做的一切就是:
sudo apt install git
sudo apt install ant
sudo apt install netbeans
但是当我尝试运行 时netbeans
,找不到该命令。安装后我离开了办公桌,所以我又运行了sudo apt install netbeans
一次。之后,netbeans
找到了命令,并且 NetBeansIDE 启动窗口显示了一段时间,但随后消失了。
现在我看了~/.netbeans/var/log/messages.log
一下java.lang.NoClassDefFoundError
。
详细地说,看来 java 已经安装在来自 osboxes 的 VM 映像中。 java -version
报告版本11.0.1 2018-10-16
。
看过其他帖子后,我做了sudo apt-get remove netbeans
以及sudo apt-get purge netbeans
然后sudo apt-get install netbeans
。这没有帮助。
更详细地说,似乎安装的 NetBeans 版本是 8.1。内容messages.log
如下:
Log Session: Friday, November 16, 2018 10:31:23 AM EST
System Info:
Product Version = NetBeans IDE 8.1 (Build 20180424-debian-8.1)
Operating System = Linux version 4.18.0-11-generic running on amd64
Java; VM; Vendor = 1.8.0_181; OpenJDK 64-Bit Server VM 25.181-b13; Oracle Corporation
Runtime = OpenJDK Runtime Environment 1.8.0_181-8u181-b13-1ubuntu0.18.10.1-b13
Java Home = /usr/lib/jvm/java-8-openjdk-amd64/jre
System Locale; Encoding = en_US (nb); UTF-8
Home Directory = /home/helmut
Current Directory = /home/helmut
User Directory = /home/helmut/.netbeans/8.1
Cache Directory = /home/helmut/.cache/netbeans/8.1
Installation = /usr/share/netbeans/8.1/nb
/usr/share/netbeans/8.1/ide
/usr/share/netbeans/8.1/java
/usr/share/netbeans/8.1/apisupport
/usr/share/netbeans/8.1/harness
/usr/share/netbeans/8.1/platform
Boot & Ext. Classpath = /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/jfr.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/classes:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/java-atk-wrapper.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/icedtea-sound.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/sunpkcs11.jar
Application Classpath = /usr/share/java/jcodings.jar:/usr/share/netbeans/8.1/platform/lib/boot.jar:/usr/share/netbeans/8.1/platform/lib/org-openide-modules.jar:/usr/share/netbeans/8.1/platform/lib/org-openide-util.jar:/usr/share/netbeans/8.1/platform/lib/org-openide-util-lookup.jar:/usr/share/netbeans/8.1/platform/lib/org-openide-util-ui.jar:/usr/lib/jvm/java-8-openjdk-amd64/lib/dt.jar:/usr/lib/jvm/java-8-openjdk-amd64/lib/tools.jar
Startup Classpath = /usr/share/netbeans/8.1/platform/core/org-openide-filesystems-compat8.jar:/usr/share/netbeans/8.1/platform/core/core-base.jar:/usr/share/netbeans/8.1/platform/core/asm-all-5.0.1.jar:/usr/share/netbeans/8.1/platform/core/core.jar:/usr/share/netbeans/8.1/platform/core/org-openide-filesystems.jar:/usr/share/netbeans/8.1/platform/core/org-netbeans-libs-asm.jar:/usr/share/netbeans/8.1/nb/core/org-netbeans-upgrader.jar:/usr/share/netbeans/8.1/nb/core/locale/core_nb.jar
java.lang.NoClassDefFoundError: org/eclipse/osgi/baseadaptor/HookConfigurator while loading org.netbeans.modules.netbinox.NetbinoxHooks; see http://wiki.netbeans.org/DevFaqTroubleshootClassNotFound
at org.netbeans.ProxyClassLoader.selfLoadClass(Unknown Source)
at org.netbeans.ProxyClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.netbeans.modules.netbinox.NetbinoxFactory.newFramework(Unknown Source)
at org.netbeans.core.netigso.Netigso.prepare(Unknown Source)
at org.netbeans.NetigsoHandle.turnOn(Unknown Source)
at org.netbeans.ModuleManager.enable(Unknown Source)
INFO [null]: Last record repeated again.
at org.netbeans.core.startup.ModuleList.installNew(Unknown Source)
at org.netbeans.core.startup.ModuleList.trigger(Unknown Source)
at org.netbeans.core.startup.ModuleSystem.restore(Unknown Source)
at org.netbeans.core.startup.Main.getModuleSystem(Unknown Source)
INFO [null]: Last record repeated again.
at org.netbeans.core.startup.Main.start(Unknown Source)
at org.netbeans.core.startup.TopThreadGroup.run(Unknown Source)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/osgi/baseadaptor/HookConfigurator
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at org.netbeans.JarClassLoader.doLoadClass(Unknown Source)
... 16 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.osgi.baseadaptor.HookConfigurator starting from ModuleCL@459c3d83[org.netbeans.modules.netbinox] with possible defining loaders [ModuleCL@459c3d83[org.netbeans.modules.netbinox]] and declared parents [org.netbeans.MainImpl$BootClassLoader@41629346, ModuleCL@7636aab3[org.netbeans.core.netigso], ModuleCL@629a3076[org.netbeans.libs.osgi]]
at org.netbeans.ProxyClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 19 more
答案1
遗憾的是,Netbeans在官方 PPA 中没有按预期启动在全新的 Ubuntu 18.xx 上,由于 Java 依赖性。
因此这里有一个替代解决方案:
删除 Java 11(与 Ubuntu 18.xx 上的 Netbeans 8.2 不兼容):
sudo apt remove netbeans
sudo apt remove openjdk-11-*
安装Java 8和Netbeans 8.2(Netbeans约214MB):
sudo apt install openjdk-8-jdk
wget https://download.netbeans.org/netbeans/8.2/final/bundles/netbeans-8.2-linux.sh
sudo sh netbeans-8.2-linux.sh
当它询问 Java 位置时选择/usr/lib/jvm/java-8-openjdk-amd64
。
安装后您可以通过以下方式访问
/usr/local/netbeans-8.2/bin/netbeans
如果您选择默认位置。