I am an Apache Ant novice and I would like to create a build file with a run task. The run task should execute the following command line statemenet
java -classpath C:/tmp/SYS/doodle.jar;C:/tmp/SYS/CTX.jar sys.ctx.doodle.Start
where the sys.ctx.doodle.Start class is located in the doodle.jar
My question is: how can I add two elements in a classpath?
I have tried the following:
<target name="run">
<java jar="C:/tmp/SYS/doodle.jar" fork="true">
<classpath>
<pathelement location="C:/tmp/SYS/doodle.jar"/>
<pathelement path="sys.ctx.doodle.Start"/>
</classpath>
<classpath>
<pathelement location="C:/tmp/SYS/CTX.jar"/>
</classpath>
</java>
</target>
But when executing it throws me a java.lang.NoClassDefFoundError
Any idea where the problem may be?
You can transpose your command-line path into the Ant
javatask classpath attribute directly. Ant should take care of recognising that is composed of semicolon-delimited jar names.Or you can specify it as a nested element as you currently have:
The argument
sys.ctx.doodle.Startlooks like the name of the class you want to run. Use theclassnameattribute to pass that to thejavatask. Putting that with the classpath leads to:The
jarattribute should be used only when you want to run theMain-Classincluded in that jar.