Multiple Projects with Eclipse

感情迁移 提交于 2019-12-21 13:01:02

问题


I have workspace inside of Eclipse which has 2 projects in it.

I want to reference project #2 from project #1, but when I go to Project -> Properties -> References, and tick the project that I want to add as a reference, I am still not able to instantiate the classes from project #2 inside of project #1.

This is a blackberry app, developed in Java and in Eclipse.

Project1 Launcher.java

Project2 Screen.java

I want to use Screen scr = new Screen(); // located in Project1


回答1:


You need to add the project to the build path so that the Eclipse Java compiler can see the other project.

  1. Select Project->Properties->Java Build Path->Projects tab
  2. Select Add...
  3. Add "Project 1" and OK back to the workspace.

One other thing to check. If your classes are in the default package they won't be imported. If they are, try moving your classes to an explicit package.

For example:

import mypackage.Screen;

...
Screen scr = new Screen(); 


来源:https://stackoverflow.com/questions/1155467/multiple-projects-with-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!