简体   繁体   中英

Use files from one Java project in another project in Eclipse

I have two Java projects - MyProject and MyProjectStubs

The MyProject has the bulk of the classes for the effort.

The MyProjectStubs has certain "dummy" classes whose processing will be replaced later by more sensitive processing - which cannot be stored on the same network as the MyProject project.

I was able to tell MyProjectStubs to "require" MyProject in order to build. But of course, I have to have the same files that are in MyProjectStubs also in MyProject , so that MyProject will build without error.

Is there a way to remove those dummy files from MyProject , and have MyProject reference the files in MyProjectStubs without creating a circular reference between the two projects?

Use interfaces. That's exactly what "dummy" files are, if you put interfaces to the classes you will develop in the future in MyProject, then implement these interface stubs in the other MyProjectStubs , MyProject will compile.

This is one of the main reasons interfaces exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM