Search code examples
javacompiler-errorscommand-promptjavac

Java command prompt compile error


I started learning Java lately, and trying to make my first program based on book which is the "Hello World" program. After writing the script on notepad, i try to compile it on the command prompt and then this notice appeared.

first I type: javac javaCode.java

then there a notice said:

    javaCode.java:2: error: <identifier> expected
    public class static void main(string[] args) {
                ^
    javaCode.java:6: error: reached end of file while parsing
    }
     ^
    2 errors

I don't have any ideas what going on here so please give detailed information and how to fix this thing.


Solution

  • public class static void main(string[] args)
    

    Remove class

      public static void main(string[] args) 
    

    class is different from method. main method syntax doesn't contain class.