The answer to this question is related to the question. When you run it through the JVM, it has access to everything, regardless of access level. When you run it through ant, which is another java program itself, it must obey the same rules as any other program, which means that it cannot see your main method.
If you declare your class as public class Main , the problem should go away.
As to why jvm made this decision to allow access to private classes at startup, this is a completely different matter. According to specification
12.1.4 Call Test.main
Finally, after the initialization for the Test class is completed (during which it may be associated with other subsequent loading, binding, and initialization), the main test method is called. The main method must be declared public, static, and invalid. It should take one argument; this is an array of strings. This method can be declared as
public static void main (String [] args) or public static void main (String ... args)
This specifically states that the method should be public , but does not say anything about the class in questions about why it works when calling main directly through the virtual machine.
Dervall
source share