Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I reference another project in Eclipse Java EE projects?

I'm wondering how can I reference another project in Eclipse Java EE projects, just like you do in normal Java Projects. In fact I'd like to be able to separate development in multiple projects and still be able to debug and work with each. Instead I can reference projects in Java EE projects, but this doesn't automatically put the Jar inside WEB-INF/lib. How do you set up to do this? This is necessary as you grow up from simple webapps to more complex ones.

like image 604
gotch4 Avatar asked Apr 07 '11 11:04

gotch4


People also ask

How do I reference another project in Eclipse?

Right click on Project1, then click on Properties. In the dialog that comes up, select Java Build Path, and then click on the Projects tab. There, add Project2 to the build path. If Project1 is a web app, you need to make sure your Deployment Assembly (same Properties UI) has Project2 there as well.

Can we call another project Java class from our project in Eclipse?

Yes. In the Project Explorer right click on it and select Properties, there go to Java Build Path and select Projects tab. Add your other project here, now you're able to use the classes from it in your current project.

How do I add a reference to a project in Java?

On the Java Build Path part of the dialog, select the Libraries tab. Click Add Library button. Select WebLogic Shared Library, and then click Next. Click Browse, and choose the library that you want to reference.

How do I add a project as a dependency of another project in Eclipse?

Instead open the project properties of the second project and select "Java Build Path". On the right side on the "Projects" tab you can add your first project as "required project on the build path". The class files of project 1 are now added to the class path of project 2.


1 Answers

This is done under Deployment Properties section of the project properties (reachable via context menu of the project).You add/remove projects, jars libraries to be assembled to your deployment unit from there.

Edit: As of Eclipse Kepler, you can find this by right-clicking the project and picking Deployment Assembly. Click Add and add the dependency project.

like image 112
Gorkem Ercan Avatar answered Nov 04 '22 18:11

Gorkem Ercan