Reputation: 34
I have 2 projects at this hierarchy
*Project1
**src
***Class1
*Project2
**src
***Main
Can i access Class1 Class that is in Project1 in Main Class that is in Project2
Is this possible OR not?
Upvotes: 0
Views: 1265
Reputation: 2547
It is, you would need to link the projects. Right click on
Project2 > Properties > Java Build Path > Projects > Add
then select your project.
If your project is in a different workspace than use
Project2 > Properties > Java Build Path > Folder > Link Source
select your folder.
Upvotes: 2
Reputation: 33534
Yes...you can..
1. What you can do is create a jar of the project you're getting the class from via Export->Java->JAR file
and put that file into your project. This will let you access the class you need while still keeping your projects self-contained.
2. Use import
, and voila....you now have the access.....
/////////////////////Edited///////////////////////
Use this to import the project in your current project...
In eclipse do this...
Build Path ---> Configure Path ----> Click Project Tab ---> Add the project.
But still using Jar
is much more easier while importing and exporting
..and you can give the version numbers
to jar, and can mention the changes in them...
Upvotes: 1