简体   繁体   中英

Ant jar Could not find or load main class

I am running a jar with a particular argument for eg: testscript run then this testscript exists in different directories so I run the jar of that script using the java jar command of ant something like this:

<java jar="testscript-jar.jar">
<arg value="run"/>
</java>

By doing that I get error Could not find or load main class .

This command works fine for the first 2-3 instances but start showing error for the rest of the directories.

Make sure the jar attribute points to the correct path of the Jar file relative to the Ant's project base dir. See this quote from the java task documentation :

The parameter of the jar attribute is of type File ; that is, the parameter is resolved to an absolute file relative to the base directory of the project, not the directory in which the Java task is run. If you need to locate a JAR file relative to the directory the task will be run in, you need to explicitly create the full path to the JAR file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM