So I have two projects in Eclipse and my main project references classes from my second project, the thing is that I am modifying both projects constantly and when I run my main project it does not always build the second project and I need that Eclipse builds both projects when I run my main project, how can I do this? sorry I am a newbie.
Asked
Active
Viewed 130 times
1
-
How are you referencing the dependency project in your main project? – vikas Sep 22 '12 at 04:48
2 Answers
0
You should check to make sure the "Build Automatically" is checked under the Project menu. After every time you save, it will rebuild everything (even if you are debugging it will usually swap it!)

Grothaar
- 206
- 1
- 2
- 8
-
-
Huh. What makes you think it's not building? If you make a Syntax in both of your projects, does Eclipse indicate an error right away? Does it indicate it after you do a clean and build all? – Grothaar Sep 22 '12 at 04:45
-
well I think it builds cause I just created another project and that project gives me the expected results every time I modify any of the projects, I think the problem is that my main project uses a previous built of my second project because right now I am running two projects and they both do the same thing but one of them uses a previous built while the other uses the latest built.... what can be wrong here? – Leonso Medina Lopez Sep 22 '12 at 05:03
-
Oh, o.k. So it _is_ building then? Just when you run the program you are seeing an older version of the second project? In that case it's probably a class path issue. Make sure that your main project has a reference to the second project under the "Projects tab". Also make sure you don't have any older jars in the libraries tab of the project. If you set a break point in your code when you get to code in your second project you can try to step through and then click on link with editor button in the package explorer. It will tell you where it thinks the jar file is. – Grothaar Sep 22 '12 at 05:13
-
Another trick you can do is try to "open Declaration" of a class in the Main project that references the second project and then see where it takes you. If you enable the link with editor button in the package explorer you'll see where it is picking up the jar file from. – Grothaar Sep 22 '12 at 05:16
-
mmm about opening the declaration I enabled link with editor but how exactly can I see where the jar file is? – Leonso Medina Lopez Sep 22 '12 at 05:45
-
If you link with the editor, you will see the location highlighted in your Package Explorer. If it is indeed a stale jar, you will see it appear under "Referenced Libraries". If it's set up correctly, you should see it under your second project. – Grothaar Sep 22 '12 at 06:00
-
well I have not created any jar files from my projects so it only shows me the class in the project explorer, which is not of much help... this is weird... – Leonso Medina Lopez Sep 22 '12 at 06:13
-
let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/16986/discussion-between-grothaar-and-leonso-medina-lopez) – Grothaar Sep 22 '12 at 06:21
0
Add The dependent project as project dependency to the Java Build Path.

Assen Kolov
- 4,143
- 2
- 22
- 32
-
So, you have a workspace with 2 projects: A and B. In A->Project Properties->Java Build Path->Projects, B is listed. You change something in B and run A, but you see code behaves as before the change. Is that what you observe? – Assen Kolov Sep 23 '12 at 09:29
-
yes that is totally what I see finally someone who know the problem – Leonso Medina Lopez Sep 25 '12 at 00:54