java 如何使用 Ant 脚本运行 main() 方法?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15636107/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run main() Method with Ant Script?
提问by M?xL
I just want to run the main()
- Method of a java class by double clicking my
the ant task in eclipse ant - view. My Problem is, I don't know how to write the ant file exactly. My ant file should be analyzeDatabase.xml
.
我只想main()
通过在eclipse ant - 视图中双击我的ant 任务来运行java 类的方法。我的问题是,我不知道如何准确地编写 ant 文件。我的蚂蚁文件应该是analyzeDatabase.xml
.
I tried something like this, but always fails:
我试过这样的事情,但总是失败:
<?xml version="1.0" ?>
<project name="DBAnalyzer" default="run" basedir=".">
<target name="run" description="runs dbanalyzer">
<java classname="DBAnalyzer">
<arg value="-h"/>
</java>
</target>
</project>
回答by Ostap Andrusiv
Change <java classname="DBAnalyzer">
to fully qualified name.
And don't forget to double-check your classpath.
更改<java classname="DBAnalyzer">
为完全限定名称。并且不要忘记仔细检查您的类路径。
<java classname="com.prostep.openpdm.db.analyzer.DBAnalyzer">
<arg value="-h"/>
<classpath>
<pathelement path="${your.java.class.path}"/>
</classpath>
</java>
Full description on Ant Java Task is here: http://ant.apache.org/manual/Tasks/java.html
Ant Java 任务的完整描述在这里:http: //ant.apache.org/manual/Tasks/java.html