3

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>();

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?

10
  • 1
    Make sure the package statement is in those classes, so they are in the right package Commented Jan 2, 2012 at 4:33
  • 1
    The package statement is in them. Commented Jan 2, 2012 at 4:36
  • It is impossible to guess which one is class and package. I think MobiTech and PlaceSaver are classes. Commented Jan 2, 2012 at 4:36
  • 3
    "any ideas?" Don't accept code from people that don't even understand how to name packages (or classes or methods or attributes) using the common nomenclature. Commented Jan 2, 2012 at 4:38
  • 1
    @AndrewLatham I think his point was that the package isn't named following standard Java conventions, although the classes, methods, and attributes are fine (except that the properties are public, which is generally frowned upon). Commented Jan 2, 2012 at 4:59

3 Answers 3

8

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.

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

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".

Sign up to request clarification or add additional context in comments.

5 Comments

I'm sorry, I've been trying for a while, but I just can't work this out. The first guide I just didn't understand what it wanted me to do, and the second one I first imported the files (had to copy the folder to a different location) and it imported them into a different package and their icon said they were built, but it gave me an error when I tried to move them back to the right package and overwrite the old ones. So I deleted the new package and tried again and this time importing them did absolutely nothing.
I also right-clicked on them and put "add to build path", which turned them into .jar files and put them in a library instead of in the package, and that built them at least because I could see all the errors, while I couldn't before. But I can't figure out what to do with them now that they're jar files.
Try making a new package, then move the Java files that you got from your friend to the new package's path (which will be in your workspace folder). Just a suggestion, see how it goes.
I actually found the solution. You can just right-click on the files, go to Build Path, and click Include. Thanks!
I landed here when I had created a class in my src/test/java folder instead of my src/main/java folder. This got me thinking enough to double-check. Much appreciated 🙏
6

I know this is an old question, but I just had a very similar problem. I came across this forum post: http://www.eclipse.org/forums/index.php/t/88625/.

As the post suggested I clicked Project->Clean, and all the unresolved type errors disappeared.

Comments

0

same happens for me here. It turns out just when the class was not built in the bin folder. Check your bin or target folder. ~

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.