1

I've just created a project on Eclipse and imported some source files (existing project). But I can't compile it ! Ok, the project has got several source files, so I wanted to compile only the Main.java file (with eclipse not in the command line, in the command line it worked!) but all what I get is this error :

http://www.screencast.com/users/Amokrane/folders/Jing/media/82d772dd-10cd-4552-b1d0-3cf18bf39f13

As you can see the Main.java file is straighforward, just a hello world !

What's the matter ?

Thanks

2
  • 1
    The problem apparently lies in the project itself. Open the Problems tab, set the filter to your project and copy here what problems you see. Commented Dec 13, 2009 at 17:44
  • Please read meta.stackoverflow.com/questions/285551/… Commented May 9, 2019 at 20:35

4 Answers 4

6

"Unresolved compilation problem" means that the class hasn't compiled successfully. Eclipse will still let you run code that doesn't compile, but any of the specific bits which don't compile will throw this error. Look in the "Problems" tab to see what's wrong.

From the look of the Package Explorer view, every single class has a problem... perhaps the file location doesn't match the package declaration? That would match the position of the pink box just to the right of the vertical scrollbar for the class - it suggests that the error is right at the top of the file, which is where the package declaration would be.

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

3 Comments

So yeah the error is : "The declared package does not match the expected package". I'm googling it (first time I use java, so I'm not really familiar with this notion of package..)
Ok it's working ! I added "package isibox;" At the begining of the Main.java file ! thx :)
You can use Ctrl-period to move to the location of the next error in the file, and then use Ctrl-1 to see what Eclipse suggests can be done at that location.
1

You have a compilation error at the top of your Main.java file, just out of sight in the screenshot. Probably an unresolvable import or a wrong/missing package declaration.

1 Comment

Yes it is ! What should I do ?
1

It is simple in my case that the imported project needs 32 bit jre to run but cannot be compiled in the same. In IDE, if you click run, it will try to compile and run the project in single shot so fails due to 32 bit jre for compilation with the above reported error. So i used 64 bit compiler and started to run and got compiled successfully but thrown error that needs 34 bit jre for some of the SWT used in the project. Again i changed the 32 bit jre and run the project, it is gone ! THE ERROR IS GONE NOW !

Comments

0

You can get the error "Exception in thread "main" java.lang.Error: Unresolved compilation problem:" if your public class name differs from your file name.

example:

File Name:

ServiceRequest.java

Inside file, class is named differently; like

public class Service

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.