public means it can be accessed from anywhere, not just within the same folder/package. This modifier is necessary so java can excecute the main method in the "subclass" class.
static means it is a class method (i.e. you don't have to have a "subclass" object before calling this method.)
void means it does not return a value.
In your first error, the static modifier is present so java can see the main method; it just can't execute it because it's in a different package.
In your second error, java can't see the main method at all since it's not static. It wouldn't make a difference in this case if you called it public void main(...) or public void cheese(...).
Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
Joined: Aug 15, 2011
Hi..Thanks for replying...
But that's not what I asked...
What I asked is the difference between those 2 error messages...
Your main class has to be public, static. If its not public compiler tell that it has to be public ( because it sees that there's a static method with name- main ). But in the second case where main method is not static, then its just any other method in the class. Hence compiler complains that it cannot find the main() method. Whereas in the first case the compiler is able to locate the main method but its visibility is not as per the rules.
You can try writing a code with public static main(String args) and public main(String args).