Sharing user libraries between projects

eclipse, java

Solution

You can put the shared libraries in an Eclipse projects `P` and make other projects depend on `P`. To make a project `Q` depend on `P` do the following:

- Select project `Q` in the package explorer, and right-click on it.

- Select `Properties` from the context menu.

- Go to the `Java Build Path` properties page.

- Go to the `Projects` tab.

- Check project `P` to add it to the build path of project `Q`.

See the article at http://www.informit.com/articles/printerfriendly.aspx?p=367962 for more details.

Problem

I'm taking some time to learn Eclipse, and later on NetBeans. I actually enjoy both IDEs. I don't know which one I prefer, but they seem to be intuitive. As for the Eclipse IDE, I'm learning about best practices for sharing my User Libraries amongst all my projects. Not to mention when I find someone else's Java code online, I certainly would like to import that code and utilize it in any place I need. I notice there's many questions on Stack Overflow about how to share assets among all the Projects. To be clear, when I say "assets", I mean anything other than where I would have my Project's main method reside. (ie: images, xml/txt files, custom classes, etc....) I come from the web development world (PHP), so my mindset is accustomed to PHP's `include()` and `require()` functions, for importing anything on the server into my application. Like most web developers I know, I keep my web assets in the same places for ease of importing. Now onto a new world, Java + Eclipse. I've created a single Project, and I am now creating additional Classes within that single Project. These Classes could be useful in practically every Project I create. After reading other questions and posts I'm still not quite sure of a Best Practice for asset sharing between Projects. (I'm only concerned about a single workspace too) I'd like to hear from others about their personal Best Practices. Do you create a Project that holds only Classes, Images, Files? Do you keep a Folder/Directory somewhere on your File System that keeps all of that, and you import it? Do you utilize Eclipse's default settings when creating a Project, or do you change anything around?

Original source