- Background information:
I have recently started learning the basics of Java programming language. To run my program at the command prompt, I downloaded the java development kit also known as JDK, and I set my windows 10 system path to:
C:\Program Files\Java\jdk-9.0.1\bin;C:\Program Files\Java\jre-9.0.1\bin
- Problem:
After writing a simple Hello World program with the following format:
class test{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
and running it on command prompt using
javac test.java
, and then writing
java test
the output says:
Error: Main method is not static in class test, please define the main method as:
public static void main(String[] args)
I have tried compiling my simple program on an online Java compiler and everything works fine.
- Edit:
As suggested using a Java decompiler. I used http://www.javadecompilers.com/result and the output was:
import java.io.PrintStream;
public class test {
public test() {} public void main(String[] paramArrayOfString) {
System.out.println("Hello World!");
}
}
- Question:
Where is the problem coming from? How can I fix it?