在eclipse中尝试在java项目中使用AST时,我得到的错误信息是运行时: 线程“main”中的异常java.lang.NoClassDefFoundError:org / eclipse / core / runtime / IAdaptable
我已经尝试在构建路径中添加core.runtime jar,但这没有帮助。
代码在开头就失败了:
AST ast = AST.newAST(AST.JLS4);
我也尝试在我的电脑中添加所有的罐子,但无济于事。任何想法?
堆栈跟踪:
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IAdaptable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at testRun.main(testRun.java:44)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IAdaptable
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 25 more
答案 0 :(得分:4)
除了在您的构建路径中添加org.eclipse.jdt.core_[version_number].jar
之外,您还需要添加 org.eclipse.equinox.common_[version_number].jar
。