Search code examples
javamavenant

Application Batch File Throws AntMain Error When Executed


I have an application that starts from IntelliJ with no problem but when I execute the start.bat from the command prompt, it throws the below message with no other information:

Error: org/apache/tools/ant/launch/AntMain

What does this error mean? I found this thread but the error message is different from what I get.

Note: It is not an environment variable problem. The batch file was working perfectly until I have changed some of the dependencies. Nothing changed on the batch file, nothing changed in my environment, only some internal dependency updates. None of these dependencies are third party libraries and they have nothing to do with Ant. Please only focus on what this error indicates because I have already tried to locate which dependency change caused the problem. The application I am working on is commercial and unfortunately, I am not able to provide more details. Thanks in advance.


Solution

  • The message indicates that AntMain class does not exist in your dependencies. Adding ant dependency is not enough. You also need to add ant-launcher dependency into the Maven structure of your project, which contains the main method.

    <dependency>
        <groupId>ant</groupId>
        <artifactId>ant</artifactId>
        <version>*</version>
    </dependency>
    <dependency>
        <groupId>ant</groupId>
        <artifactId>ant-launcher</artifactId>
        <version>*</version>
    </dependency>