2015-07-04 84 views
1

我正在运行一个特殊的参数为例如:testscript run然后这个testscript存在于不同的目录中,所以我运行这个脚本jar使用java的这个蚂蚁的jar命令这样的事情:Ant jar找不到或加载主类

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

通过这样做,我得到错误Could not find or load main class

该命令适用于前2-3个实例,但对其余目录开始显示错误。

回答

1

确保jar属性指向相对于Ant的项目库目录的Jar文件的正确路径。看到这个报价从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.

+0

所以jar参数和位置参数是一样的吗?或罐只是名称,位置是确切的位置? 另外我需要通过蚂蚁文件做所有事情 – fscore

+0

@fscore忘记'位置'。确保'jar'设置为相对于基本目录的正确路径。 – manouti

+0

嗯,我试着你说的,我得到“错误:无法访问jar文件”的一些文件的作品,但对于一些它给出的错误“错误:无法访问jar文件” – fscore

相关问题