Reputation: 13150
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?
Upvotes: 3
Views: 5554
Reputation: 7394
There is another better way of doing it.
Using Projects as dependencies for other Projects may seems easier...
But that should be only done if we want to use that project as library project.
Else if we just want to do sharing user libraries between projects, than following approach is better.
Create Linked Folder containing libraries, as follows:
- Right click on project.
- Click on New, and select new folder.
- Go to advance.
- Choose your lib directory.
- Click on ok.
- Right click on project.
- Go to properties.
- Go to Java Build Path.
- Go to libraries tab.
- Click on Add Jars... and import required jars from /libs directory.
- Click on ok.
Upvotes: 0
Reputation: 14728
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:
Q
in the package explorer, and right-click on it.Properties
from the context menu.Java Build Path
properties page.Projects
tab.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.
Upvotes: 7