s*i 发帖数: 31 | 1 In eclipse, i have project 1, where i define 2 classes and make them both
belong to a package i define (eg: com.myPackage).
Then i create project 2, and i want to use those 2 classes from project 1.
It seems that i can accomplish this two ways:
1) Go to Java Build Path->Projects, add Project 1 as a "Required project"
for Project 2. And write "import com.myPackage.*" statement at the top of
Project 2's source code.
2) Go to Java Build Path->Libraries, click "Add Class Folder", and choose
the fo | k***r 发帖数: 4260 | 2 i'd imagine method 1 would make project 1 a dependency of project 2
and will force compilation of project 1 when project 2 is compiled,
instead of just the a few classes in method 2.
【在 s*i 的大作中提到】 : In eclipse, i have project 1, where i define 2 classes and make them both : belong to a package i define (eg: com.myPackage). : Then i create project 2, and i want to use those 2 classes from project 1. : It seems that i can accomplish this two ways: : 1) Go to Java Build Path->Projects, add Project 1 as a "Required project" : for Project 2. And write "import com.myPackage.*" statement at the top of : Project 2's source code. : 2) Go to Java Build Path->Libraries, click "Add Class Folder", and choose : the fo
| p******e 发帖数: 897 | 3 actually 1) is more standard than 2), use 1) you can make sure project 2
always get latest code from project 1 and you don't need to hard code
project 1 output directory in project 2 class path
【在 s*i 的大作中提到】 : In eclipse, i have project 1, where i define 2 classes and make them both : belong to a package i define (eg: com.myPackage). : Then i create project 2, and i want to use those 2 classes from project 1. : It seems that i can accomplish this two ways: : 1) Go to Java Build Path->Projects, add Project 1 as a "Required project" : for Project 2. And write "import com.myPackage.*" statement at the top of : Project 2's source code. : 2) Go to Java Build Path->Libraries, click "Add Class Folder", and choose : the fo
| k***r 发帖数: 4260 | 4 hmmm. i have never had to modify output directory in eclipse ...
Am I missing anything?
【在 p******e 的大作中提到】 : actually 1) is more standard than 2), use 1) you can make sure project 2 : always get latest code from project 1 and you don't need to hard code : project 1 output directory in project 2 class path
| p******e 发帖数: 897 | 5 most time you don't need, default output directory is good enough, but you
can easily change this property.
And if you use option 2), each time you change the output directory, you
must remember change the project 2 class path too.
【在 k***r 的大作中提到】 : hmmm. i have never had to modify output directory in eclipse ... : Am I missing anything?
|
|