I’m trying to make a buildfile for a java class with a main method which uses command line arguments. But the run-target of the buildfile isn’t able to find the classe even though the path should be correct.
This is the code of the buildfile:
<project name = "." default = "run" basedir =".">
<description>
BuildFile for APPDrawEvent.java
</description>
<property name = "build.dir" location = "./build"/>
<property name = "src.dir" location = "./src"/>
<property name = "doc.dir" location ="./documentation"/>
<property name = "file" location ="AppDrawEvent"/>
<target name="init">
<mkdir dir="${build.dir}"/>
<mkdir dir = "${doc.dir}"/>
</target>
<target name ="compile" depends = "init">
<javac srcdir = "${src.dir}"
destdir = "${build.dir}"
includeantruntime = "false"/>
</target>
<target name = "document" depends = "compile">
<javadoc destdir = "${doc.dir}">
<fileset dir = "${src.dir}" />
</javadoc>
</target>
<target name="run" depends="compile, input-runargs" description="run the project">
<java sourcefile="${build.dir}/AppDrawEvent" fork = "true">
<arg line="${args}"/>
</java>
</target>
<target name="input-runargs" unless="args" description="prompts for command line arguments if necessary">
<input addProperty="args" message="Type the desired command line arguments: "/>
</target>
</project>
The AppDrawEvent class is in the ./build directory which can be found in the directory the buildfile is located in.
All the other targets except the run-target are executing as they should be. The directory path should also be correct and the files are compilated into the build-directory, so I’m at a loss why my buildfile doesn’t find the class.
PochitaFanboy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.