Reputation: 1856
I have 2 java projects ProjectA (java web app) and ProjectB (contains other java classes) in my eclipse IDE. e.g.
ProjectA ProjectB
|_HelloWorld.java |_PrintHelloWorld.java
|_HelloWorld( |_print()
new PrintHelloWorld().print()
)
So ProjectA has a class with a method that is calling a method from a class in ProjectB. In Order to get these projects to build, I have built ProjectB and added the jar as a dependency on ProjectA's build-path. So I don't get any compilation errors and the project seems to build fine.
However, when I debug through the code. I get ClassNotFoundException
at the line where ProjectA calls the method in project B
Does anybody know what I am doing wrong/have missed out?
Upvotes: 0
Views: 2515
Reputation: 61
Using the following steps add the project to Deployment Assembly.
right click on project > Properties > Deployment Assembly > Add > Project > Select the project to be added as the dependency and then click Apply and Ok.
This worked for me after trying several options.
Upvotes: 3
Reputation: 36
Create a war file if the needed classes are in that.
The compiler build path is not the same as the deploy path. You may need to explicitly add the dependent jar in the Deployment Assembly option
Upvotes: 0
Reputation: 59690
Build Path-->configure build path
Add
button.OK
.Note:- This will be helpful when you are running your application in eclipse. When building it make sure to build ProjectB and add it to ProjectA at proper place.
Hope this helps.
Upvotes: 0
Reputation: 274778
Instead of adding ProjectB's jar to ProjectA, add the whole project as a dependency as follows:
ProjectA Properties > Java Build Path
Projects
tabLink to Eclipse User Guide.
Upvotes: 1