Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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"?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!