I want to compile and then execute my program, giving it 2 input parameters. Why doesn't it work?
<?xml version="1.0" encoding="UTF-8"?>
<project default="run" name="MyProgram compile and run">
<target name="run" depends="compile">
<classpath path="." />
<exec executable="MyProgram">
<arg value="80"/>
<arg value="C:/"/>
</exec>
</target>
<target name="compile">
<javac srcdir="." destdir="." />
</target>
</project>
Exactly what are you trying to do? You're compiling a bunch of Java code, and then using
exec
to executeMyProgram
. Is that file namedMyProgram.exe
? Or, is this Java code?If
MyProgram
the java code you're compiling via thejavac
, you may need to use the<java>
task which runs the Java Runtime Engine to execute the compiled*.class
files.I am going to assume you have a single Java file called
MyProgram.java
, and you want to compile it and executeMyProgram.class
.