-
Unable to compile
Hello everyone,
I am new to Java and just started coding. I wrote first class which failed to compile :(
Code:
public class MainClass {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
I tried to compilie it using javac command from the console but got this error message:
Code:
Test.java:5: class MainClass is public,
should be declared in a file named MainClass.java
I hope I have provided sufficient information. Kindly look into this.
- Gapper
-
have u saved the application as "MainClass.java"??????????
-
Welcome to the Java Forums gapper. Error messages provide excellent clues for you to solve your compilation problems.
See you around!