问题
I'm trying to use eclipse jdt
, and I tried to import related modules in java source file.
I have a bunch of errors as the jdt libraries are not in Java Build Path.
I tried to open Add Libary -> Plug-in Dependencies
, but it doesn't have the jdt jar files.
I could use Add External JARs
to point to all the jar files, but I don't think it's a good idea considering I have to do the same thing over and over again with new projects.
In this case, how to put eclipse jdt jar libraries in Java Build Path? The java.util.Collection
is found automatically. I guess there might be some easy way to setup so that jdt jar files are found automatically.
回答1:
Assuming your project is an eclipse plugin project you can add the jdt as a dependency and the jars will be automatically added to the plugin dependencies
回答2:
Normally, I had to use eclipse plugin for using jdt for accessing the files in the workspace, and getting the jar files and such.
However, I found this solution to be very useful for using jdt/ask. The idea is to use string as an input to the jet, and import the related jars for using the jdt APIs.
http://www.programcreek.com/2011/01/a-complete-standalone-example-of-astparser/
I had to open Configure Build Path
.
Then, I could select and import all the jar files that I downloaded from the site.
Now, I am ready to use the libraries.
回答3:
In you Java Build Path
screen, you notice two bottons Add Variable
and Add Liberary
below Add External Jars
. Use those options and define a new variable or new user library; Once done, add the same in the project build path.
For newer project, you can simply reuse the variable/user library.
java.util.Collection
is found as it is added as library in your build path(see first item in your screenshot). I am suggesting to do the same by introducing an User Library
.
来源:https://stackoverflow.com/questions/12866991/how-to-put-eclipse-jdt-jar-libraries-in-java-build-path