tags:

views:

43

answers:

3

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 are 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?

A: 

Yes create a new project and export as .jar.

InsertNickHere
A: 

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!

Carl Smotricz
A: 

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.

Thorbjørn Ravn Andersen