简体   繁体   English

在Eclipse中导入项目

[英]importing project in Eclipse

Hello I am new to Eclipse (and I am a novice in Java): I am creating a project which should make use of some classes from another project. 您好,我是Eclipse的新手(并且我是Java的新手):我正在创建一个项目,该项目应该利用另一个项目中的某些类。 Do I have to export necessarily this last project as JAR file and add in my project? 我是否必须将最后一个项目导出为JAR文件并添加到我的项目中? Are there other alternatives? 还有其他选择吗?

There are several alternatives: 有几种选择:

  • If project A depends on project B, and both projects are in the same Eclipse workspace, you can just project B to project A's build path (project properties / build path / project). 如果项目A依赖于项目B,并且两个项目都在同一个Eclipse工作区中,则可以仅将项目B映射到项目A的构建路径(项目属性/构建路径/项目)。 This has the nice advantage that it will (optionally) automatically pull in project B's JARs, plus updates to B will be used automatically by A, and you can debug into B's code (even using hot code replace). 这样做的好处是,它可以(可选)自动引入项目B的JAR,并且A将自动使用对B的更新,并且您可以调试B的代码(甚至使用热代码替换)。
  • If A and B are fairly separate, just make B into a JAR (or several ones), then add these to A's build path. 如果A和B相当分开,只需将B制成一个JAR(或几个),然后将它们添加到A的构建路径中。
  1. If you have the source of those class files you can just link that source 如果您拥有这些类文件的源代码,则只需链接该源代码
  2. Or add the other project as a dependent project. 或将另一个项目添加为从属项目。
  3. Or create a jar of those classes and add that in lib. 或创建一个包含这些类的jar并将其添加到lib中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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