最近,尝试在 Ubuntu 18.04 中使用 NetBeans 10,但在启动时显示一条错误消息:
Activation failed: StandardModule:org.netbeans.modules.db jarFile:
/usr/share/netbeans/10.0/ide/modules/org-netbeans-modules-db.jar:
java.lang.UnsupportedClassVersionError:
org/netbeans/lib/ddl/DBConnection has been compiled by a more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file versions up to 54.0
我尝试使用 OpenJDK 8 和 OpenJDK 11 运行 NetBeans,但似乎无法摆脱此错误。我没有找到有用的提示,只是针对旧版本的 NetBeans,而且它们实际上不起作用。
停用相应模块后,NB 启动但在日志中显示“意外异常”:
java.lang.IllegalStateException:
Cannot call getCompilationUnit() if current phase < JavaSource.Phase.PARSED.
You must call toPhase(Phase.PARSED) first.
at org.netbeans.modules.java.source.parsing.CompilationInfoImpl.getCompilationUnit(Unknown Source)
at org.netbeans.api.java.source.CompilationInfo.getCompilationUnit(Unknown Source)
at org.netbeans.modules.java.JavaNode$IconTask$SourceIcon$1.run(Unknown Source)
at org.netbeans.modules.java.JavaNode$IconTask$SourceIcon$1.run(Unknown Source)
at org.netbeans.api.java.source.JavaSource$MultiTask.run(Unknown Source)
at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(Unknown Source)
at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(Unknown Source)
at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(Unknown Source)
at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(Unknown Source)
at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(Unknown Source)
at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(Unknown Source)
at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(Unknown Source)
at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(Unknown Source)
at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Unknown Source)
at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(Unknown Source)
at org.netbeans.modules.parsing.api.ParserManager.parse(Unknown Source)
at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(Unknown Source)
at org.netbeans.api.java.source.JavaSource.runUserActionTask(Unknown Source)
at org.netbeans.modules.java.JavaNode$IconTask$SourceIcon.computeIcon(Unknown Source)
at org.netbeans.modules.java.JavaNode$IconTask.run(Unknown Source)
at org.openide.util.RequestProcessor$Task.run(Unknown Source)
at org.netbeans.modules.openide.util.GlobalLookup.execute(Unknown Source) [catch]
at org.openide.util.lookup.Lookups.executeWith(Unknown Source)
at org.openide.util.RequestProcessor$Processor.run(Unknown Source)
此异常不同于那个。
最烦人的是,导航器不再工作。后两个错误可能是这些异常的副作用,但我不确定。此错误已报告对于 Debian。
我也试过那安装指南:我已更新JAVA_HOME
至/etc/environment
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64/bin/java"
它效果更好,但我仍然得到很多空指针异常当 NetBeans 解析代码时。