What is the difference between java.lang.NoSuchMethodError main Exception in thread "main " and Error: Main method not found in class

Viewed 105

I have this class

public class demo3 {
    private static  void sum()
    {       
    }
}

when I tried to run this class, I expected the error to be java.lang.NoSuchMethodError main Exception in thread "main "

however, the output was a bit different and I got below message

Error: Main method not found in class demo3, please define the main method as:
   public static void main(String[] args)

now this got my curiosity as to in which case I will get java.lang.NoSuchMethodError or in which case I will get the other error message.

1 Answers
Related