Amokrane Chentir
Amokrane Chentir

Reputation: 30385

Exception in thread "main" : java.lang.error

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

Upvotes: 1

Views: 22266

Answers (4)

Tom Stickel
Tom Stickel

Reputation: 20411

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

Upvotes: 0

Vijayakanth G
Vijayakanth G

Reputation: 11

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 !

Upvotes: 1

Michael Borgwardt
Michael Borgwardt

Reputation: 346317

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.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1500805

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

Upvotes: 6

Related Questions