I am totally new to ant and I want to send the arguments 4 4 and 50 to my JAVA main class. This is what I have so far.
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
<arg value ="4"/>
<arg value ="4"/>
<arg value ="40"/>
</java>
</target>
The error i get is:
BUILD FAILED`C:\Users\Admiral Sudoku\Documents\Eduboard\Ken Ton\build.xml:40: The element typ
e "target" must be terminated by the matching end-tag "</target>".
Missing quote at:
<arg value ="40"/>
^---- here
Also you closed <java
tag twice:
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true">
^--- non need for /
And your snipped should be inside <project>
tag.
Also you can "debug" your xml syntax easier if you open build.xml
in browser. (for example in Firefox).
Please use this.
<?xml version="1.0" encoding="UTF-8"?>
<project name="TestApp" basedir="." default="main">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
<property name="jar.dir" value="jar"/>
<property name="main-class" value="AppRunner"/>
<target name="clean">
<delete dir="${classes.dir}"/>
<delete dir="${jar.dir}"/>
</target>
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true">
<arg value="12"/>
<arg value="15"/>
<arg value="17"/>
<arg value="18"/>
<arg value="20"/>
</java>
</target>
<target name="main" depends="run"/>
</project>
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.