Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting Common Java Package

I have a project that Contains a bunch of java packages that I have recently understood are needed in a new project that I'm going to develop. I want these two projects to have the same code base so I don't have to update the common libraries in both. How can I achieve this in Exlipse?

my current set up is like this

Project1
  CommonPackage
  SpecifictProjectCode1

Project2
  SpecifictProjectCode2

I want the following, I think:

Project1
  CommonPackage
  SpecifictProjectCode1

Project2
  CommonPackage
  SpecifictProjectCode2

CommonCodeProject

What is the best way to achieve this I understand I could extract a jar file or and include it in both project but I want to be able to debug the code and I also want to keep the code editable. Is it perhaps better to extract the code to a separate project and how do I go about doing that?

Any help is appreciated.

like image 918
Pablo Jomer Avatar asked Dec 04 '25 17:12

Pablo Jomer


1 Answers

You can have three different projects in Eclipse: CommonCodeProject, Project1 and Project2. Then, Project1 and Project2 would have a dependency on CommonCodeProject.

To add a dependency on a project in Eclipse, go to Java Build Path and add the CommonCodeProject in the Projects tab.

like image 118
Dan D. Avatar answered Dec 06 '25 08:12

Dan D.