sharsour
sharsour

Reputation: 119

how to run the java class file using ant

I am trying to execute the class file in a jar through ant script. I ran the command through CMD it worked fine Command is like :-

java com.CodeReview -p “<Project Path>”

I tried to run this command through the ant script

<target name="build">
<java fork="true" failonerror="yes" classname="com.CodeReview">
<arg line="-p"/>
<arg line="D:\Test"/>
</java>
</target>

It is giving me error build: [java] Error: Could not find or load main class com.CodeReview

but through command line it is working and no issue with classpath. Do I need to set classpath in script also.

Upvotes: 0

Views: 836

Answers (1)

amphibient
amphibient

Reputation: 31338

You are missing the classpath within your java task:

<classpath>
   <pathelement location="yourjar.jar"/>
   <pathelement path="${java.class.path}"/>
 </classpath>

Upvotes: 1

Related Questions