我可以将 org.eclipse.jdt.core 导入 Netbeans 吗? [英] Can I import org.eclipse.jdt.core into Netbeans?
问题描述
我正在 Netbeans 中开发的项目中使用 this 项目.基本上,我将 3 个源代码文件复制到我的项目中,并对 Main.java
文件进行了一些调整,以便我能够在我的项目中使用它.
I am using a this project on the project that I am developing in Netbeans. Basically, I copied the 3 source code files to my project and did some tweaks to the Main.java
file in order for me to be able to use it in my project.
然后编译器说package org.eclipse.jdt.core.compiler不存在
用于以下导入:
The compiler then said that package org.eclipse.jdt.core.compiler does not exist
for the following imports:
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
我尝试通过转到 Project Properties
> Libraries
> Module Dependencies
> Add
来添加模块依赖项并输入 org.eclipse.jdt.core.compiler
但没有找到库.通常,可用库显示为它们名称的一种类型.在这种情况下,没有显示任何内容.
I tried to add the module dependency by going to Project Properties
> Libraries
> Module Dependencies
> Add
and typing org.eclipse.jdt.core.compiler
but no library was found. Usually, the available libraries are shown as one types their name. In this case, none was shown.
所以,我从 here 并通过转到Project Properties
> Libraries 将其添加到项目中
> Wrapped JARs
> 添加JAR
.编译错误消失了,我可以运行项目了.
So, I downloaded org.eclipse.jdt.core
jar from here and added it to the project by going to Project Properties
> Libraries
> Wrapped JARs
> Add JAR
. The compilation errors disappeared and I was able to run the project.
但是,当到达行 ASTParser parser = ASTParser.newParser(AST.JLS3);
时,会引发以下异常.
However, when the line ASTParser parser = ASTParser.newParser(AST.JLS3);
is reached, the following exception is thrown.
线程main"中的异常 java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/resources/IResource
我假设此异常与我在 Netbeans 的模块依赖项中找不到库的事实有关.
I am supposing that this exception and the fact that I couldn't find the library in the module dependecies in Netbeans are related.
这是否意味着我不能在 Netbeans 中使用 org.eclipse.jdt.core
还是有其他问题?有人可以帮我吗?
Does this mean that I cannot use org.eclipse.jdt.core
in Netbeans or is there another problem? Can someone help me?
推荐答案
要在普通(非 OSGi,不是基于 Eclipse 的)Java 应用程序中使用 Eclipse ASTParser,您需要遵循 JAR:
To use the Eclipse ASTParser in a plain (non-OSGi, not Eclipse-based) Java application you need following JARs:
- org.eclipse.core.contenttype
- org.eclipse.core.jobs
- org.eclipse.core.resources
- org.eclipse.core.runtime
- org.eclipse.equinox.common
- org.eclipse.equinox.preferences
- org.eclipse.jdt.core
- org.eclipse.osgi
- org.eclipse.text
所有这些 JAR 都可以在 Eclipse SDK ZIP 文件中找到,您可以从 Eclipse 项目下载该 ZIP 文件下载网站,例如.G.Eclipse 4.7.3a SDK.由于这些 JAR 不依赖于平台,因此您选择哪种操作系统并不重要.例如,您可以选择 eclipse-SDK-4.7.3a-win32-x86_64.zip.
All these JARs can be found in an Eclipse SDK ZIP file that you can download from the Eclipse Project Downloads website, e. g. Eclipse 4.7.3a SDK. Since these JARs are not platform-dependent, it doesn't matter which operating system you choose. For example, you can choose eclipse-SDK-4.7.3a-win32-x86_64.zip.
在 ZIP 文件中,您将在子目录 plugins
中找到
(相应的源代码为
).
In the ZIP file, you will find the JARs in the subdirectory plugins
as <id>_<version>.jar
(the corresponding source code as <id>.source_<version>.jar
).
这篇关于我可以将 org.eclipse.jdt.core 导入 Netbeans 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!