houdriwiokug houdriwiokug - 3 months ago 8
Java Question

Java Error Exception in thread "main" java.lang.Error: Unresolved compilation

I'm learning Java programming language and I'm pretty much newbie.. I'm using Eclipse and I'm also following theneweboston tutorials playlist. Basically I have written this code just like the tutor:

class apples{
public static void main(String args[]){
System.out.println("Hello World!");
}
}


And this code actually runs in cmd but whenever I run it in Eclipse I receive this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at pouya.apples.main(apples.java:2)

So can you help me what's going wrong here?

Answer

You need to add public to the class and you should start apples with a capital A:

public class Apples {
    public static void main(String args[]){
        System.out.println("Hello World!");
    }
}

save this in puoya/Apples.java. Compile and run it

Comments