Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFound invoking Java from ANT  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

My ANT task, which aims to invoke a Java class, specifies this:

<target name="callJava">
<java classname="MyHelperClass">
<arg value="xyz"/>
<classpath>
<pathelement path="${java.class.path}"/>
<pathelement path="${dirPath}/actions/java/"/>
</classpath>
</java>
</target>

The MyHelperClass.class is compiled in the folder "${dirPath}/actions/java/".

However, when I run the ANT script I get :
java.lang.NoClassDefFound: MyHelperClass

Has anybody any ideas? I'm sure I've had similar ANT scripts run successfully with almost identical situations.

All ideas greatly appreciated,

Jordan.
 
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of ant are you using? Are you sure that your callJava build target is exactly like you posted?

I don't get a NoClassDefFound exception unless I add fork="true" to the java task, I get this with 1.6.2 and 1.5.4:

[java] Could not find MyHelperClass. Make sure you have it in your classpath

Did you try running ant with -v (verbose) option. Sometimes an error will be obvious with the verbose output.

Is your class defined in a package? Can you run it on the command-line with "java MyHelperClass xyz"?
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!