我可以将org.eclipse.jdt.core导入Netbeans吗? [英] Can I import org.eclipse.jdt.core into Netbeans?
问题描述
我正在我在Netbeans中开发的项目上使用此项目.基本上,我将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 does not exist
用于以下导入:
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.
所以,我从Project Properties
> Libraries
> Wrapped JARs
> Add 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 Project下载下载网站,e. G. Eclipse 4.7.3a SDK .由于这些JAR与平台无关,因此选择哪种操作系统都没有关系.例如,您可以选择
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
中找到<id>_<version>.jar
(相应的源代码为<id>.source_<version>.jar
).
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屋!