包内无法识别Java类 [英] Java class not recognized within package

查看:321
本文介绍了包内无法识别Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友和我正在使用GitHub进行项目合作,我刚刚下载了他的软件包。他在NetBeans中编写了它,我在Eclipse中使用它。包中的四个类有常规图标,白色页面有蓝色J.但是其他三个有白页,但是有一个蓝色J的轮廓而不是填充的J.这四个常规类都扩展到了类然后是方法/属性树,但是在Package Explorer中根本不扩展三个奇数类。当我尝试引用常规类中的一个奇数类时,即

My friend and I are using GitHub to collaborate on a project, and I just downloaded a package he had. He wrote it in NetBeans and I'm using it in Eclipse. Four of the classes in the package have the regular icon, a white page with a blue J. But three others have a white page, but there's an outline of a blue J instead of a filled J. The four regular classes all expand into class and then method/property trees, but the three odd classes don't expand at all in the Package Explorer. When I try to reference one of the odd classes in a regular one, i.e.

List<Reminder> list = new ArrayList<Reminder>();

它在类提醒当我用光标悬停在它上面时,它告诉我添加一个import语句,但当我点击它所说的不添加import语句的地方时。当我尝试自己输入import语句时,即

It puts a red underline under the class Reminder and when I hover over it with my cursor, it tells me to add an import statement, but when I click on where it says that it doesn't add the import statement. When I try to type in the import statement myself, i.e.

import MobiTech.PlaceSaver.Reminder;

它表示导入无法解决。用于声明类的语法似乎是正确的:

It says the import can not be resolved. The syntax used for declaring the class seems to be correct:

public class Reminder
{
public Location location;
public String message;
//Reminder radius in meters
double radius = 1.0;

public Reminder()
{
}
public Reminder(Location l, String m)
{
    message = m;
    location = l;
}

public Reminder(Location l, String m, int r)
{
    message = m;
    location = l;
    radius = r;
}

我不知道发生了什么,有什么想法吗?

I don't see what's going on, any ideas?

推荐答案

你应该看一下这个。似乎蓝色J的轮廓是该列表中的第二个,这意味着Java文件不在构建路径上。按照指南将它们添加到项目的构建路径中。

You should take a look at this. It seems the "outline of the blue J" is the second one on that list, which means that Java file is not on a build path. Follow this guide to add them to your project's build path.

编辑:或 one,那个很好很简单。转到2.将现有文件添加到项目中。

or this one, that one's nice and simple. Go down to "2. Adding existing files to the project".

编辑2:正如OP在下面的评论中所说,要将现有代码添加到项目中,右键单击包浏览器中的(包或目录),然后选择构建路径 - >包含。

Edit 2: As the OP said in the comment below, to add the existing code to the project, right click on it (the package or directory) in the package explorer, then select "Build Path -> Include".

这篇关于包内无法识别Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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