简体   繁体   中英

Output of java task in Ant

I have a .java file and am compiling it using javac in ant. The .class file goes to output directory. A.class when ran, produces a.txt.

How to run the ant ´java´ task and where will the a.txt go, when ran? I mean which directory? Can I specify the direc. where the output files of java task should go?

Take a look at this for reference:

http://ant.apache.org/manual/Tasks/java.html

It contains an example of using the Java task to run a specific class, eg:

<target name="run">
     <java classname="A">
             <classpath>
               <pathelement location="output"/>
               <pathelement path="${java.class.path}"/>
             </classpath>
     </java>
</target>

It really depends on where you are writing the file out to from A.java. If it is in the current directory, eg:

File f = new File("./test.txt");
f.createNewFile();

then it will output the file relative to where you ran the build file from.

Hope that helps.

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