creating a jar for a project in Eclipse
I am using Eclipse and I have just started working on a project that needs another project (say pjkt) to function. The pjkt project files ar开发者_开发技巧e stored in a specific folder. I would like to create a jar from pjkt and then add this jar to my project buildpath. How do I do this? Do I need create first in Eclipse a new project from the pjkt code, build it and then select the export command?
Yes create a new project and export as .jar.
To answer the question about the build path:
- Create a project directory (in the using project) for library files - it's common to create it in parallel to
/src
and/bin
and call it/lib
; - Once you've created (by exporting) your jar from the used project, copy it into the
/lib
directory; - If you did any of this creating and copying outside of eclipse, refresh your project so everything will show up in the Project Explorer;
- In the Project Explorer, right-click on the .jar in the
/lib
folder and do "Build Path | Add to Build Path".
Done!
If you need to work on both projects, and have them open in Eclipse at the same time, another approach is to open Properties -> Build Path for the new project, and add pjkt on the Project Dependencies tab. This will provide all the exported resources from pjkt to the master project.
精彩评论