I have a question on Eclipse (I am using Helios).
When a project depends on various libraries, we add them to the classpath via the Build Path Dialog.
In the same dialog though, there is a tab for Projects (Required Projects on the build path).
It is not clear to me, when someone would add such a reference from one project to another.
I mean, if projectA needs functionality from projectB, then we can make a jar out of projectB and use it in projectA.
But when, would we add then, a reference from projectA to projectB, in order to need projectB in the build path of projectA?
Could someone please give an example?
Thank you!

- 52,998
- 69
- 209
- 339
3 Answers
Well, there are two reasons for depending on a project.
- You can "click through" to the source code of the other project when its code is invoked.
- If you're building and running the application in Eclipse for dev purposes, changes in the code will instantly be picked up.
Update: I thought of a third one, possibly even better than the first two. There is an "Order and Export" tab in the same screen, where you can select which elements of a project's classpath are exported. And what "exported" means here is exactly that if project B is configured to have project A as a dependency, then it will automatically add all the exported libraries from project A to its own classpath. So if project A has a lot of thrid party libraries, you don't have to manually add them to project B's classpath.

- 48,926
- 12
- 77
- 104
"Required Projects" allow you to state dependencies between projects without the need to build a jar each time you make a change to the project you depend upon.

- 5,161
- 25
- 20
-
Yes, it is simply a convenience. A very nice one at that! – Robin Jan 26 '11 at 20:47
-
So the idea is that you import for example class X from package a.b.c and then you point a reference to ProjectB which defines it? – Cratylus Jan 26 '11 at 20:48
-
Yes, that'is it. It adds the contents of the specified project into your classpath. – ChrisJ Jan 26 '11 at 20:49
One (for me nice, for others; perhaps, blasphemous) use of the "Project Dependancy" is when you have a seperate project for unit tests. Make the unit test project depend on the to-be-tested project. Of course, this is only nice if you are not a maven or hudson or blah, blah, blah user (like me). Not that blah, blah, blah are bad things.

- 37,124
- 11
- 56
- 82