Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant - Java command - IllegalAccessException

Tags:

ant

I need to run java class using ant. But when i run a class file, it throws IllegalAccessException.

this is my ant code:

<target name="test">

    <java classname="A" classpath=".">
    </java>
</target>

I got this exception when i run this target script.

[java] java.lang.IllegalAccessException: Class org.apache.tools.ant.taskdefs.ExecuteJava can not access a member of class A with modifiers "public static"
     [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:180)

This is my java program

class A
{
    public static void main(String[] args) 
    {
        System.out.println("Hello java!");
    }
}

Where im going wrong?

thanks, Srinivasan R.

like image 704
Srinivasan Avatar asked Dec 18 '25 00:12

Srinivasan


1 Answers

your class A must be public:

public class A {

    public static void main(String[] args) {
        System.out.println("Hello java!");
    }
}
like image 66
Vladimir Avatar answered Dec 20 '25 23:12

Vladimir