多个项目与Eclipse [英] Multiple Projects with Eclipse

查看:245
本文介绍了多个项目与Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作区的Eclipse其中有2个项目在这里面。

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

我想从项目#1引用项目#2,但是当我去项目 - >属性 - >参考,并勾选我想添加为参考项目,我仍然不能够实例化类从项目#2#项目1内。

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.

这是一个黑莓应用程序,Java和Eclipse中开发的。

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

PROJECT1
Launcher.java

Project1 Launcher.java

Project2的
Screen.java

Project2 Screen.java

我想用屏幕SCR =新画面(); //位于PROJECT1

推荐答案

您需要将项目添加到构建路径,以便Eclipse Java编译器可以看到其他的项目。

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


  1. 选择项目 - >属性 - > Java构建Path->项目标签

  2. 选择添加...

  3. 添加项目1,确定返回到工作区。

还有一件事来检查。如果你的类在默认包,他们将不会导入。如果是这样,请尝试移动类明确的包。

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.

例如:

import mypackage.Screen;

...
Screen scr = new Screen();

这篇关于多个项目与Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆