简体   繁体   English

在eclipse中的另一个项目中使用一个项目的包

[英]Using a project's package in another project in eclipse

how can I use the classes of a package out of the main project where it has been defined?如何在定义包的主项目之外使用包的类? for example imagine there is an Employee class in package people which belongs to ProjectOne.例如,假设在属于 ProjectOne 的包 people 中有一个 Employee 类。 let's assume Employee is needed in another project (ProjectTwo) with the same features.What should I do there?让我们假设在另一个具有相同功能的项目 (ProjectTwo) 中需要 Employee。我应该在那里做什么?

Right-click on ProjectTwo in the Package Explorer.在包资源管理器中右键单击 ProjectTwo。 Go to Build Path -> Configure Build Path.转到构建路径 -> 配置构建路径。 Go to the Projects tab, click Add, select ProjectOne, and click OK, then click OK again to exit the project properties window.转到“项目”选项卡,单击“添加”,选择“ProjectOne”,然后单击“确定”,然后再次单击“确定”退出项目属性窗口。

Then import your classes as usual - within ProjectTwo, you should be able to see ProjectOne's classes as if they were in the same project.然后像往常一样导入您的类 - 在 ProjectTwo 中,您应该能够看到 ProjectOne 的类,就像它们在同一个项目中一样。

Since i dont know wich eclipse your using i tryed this on eclipse kelpler因为我不知道你的使用会导致什么 eclipse,所以我在 eclipse kelpler 上尝试了这个

you can Drag packages into the other Projects src folder to use them您可以将包拖到其他 Projects src 文件夹中以使用它们

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

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