class Main {
public static void main(String[] args) {
....
}
}
Starting the program through the shell: java Main
works as expected but starting the program through ant:
<target name="run" depends="cmp">
<java classname="Main" classpath="."/>
</target>`
causes this error:
java.lang.IllegalAccessException: Class org.apache.tools.ant.taskdefs.ExecuteJava can not access a member of class Main with modifiers "public static"
JLS Section 12.3.3 Resolution of Symbolic References:
IllegalAccessError: A symbolic reference has been encountered that specifies a use or assignment of a field, or invocation of a method, or creation of an instance of a class, to which the code containing the reference does not have access because the field or method was declared private, protected, or default access (not public), or because the class was not declared public.
So org.apache.tools.ant.taskdefs.ExecuteJava
can't execute the method because it's enclosing class is private, but if I start the jvm pointed at a .class with a private method, it doesn't go through the same security mechanism?
This question is similar but I still don't understand