Java – ant’s java task can’t find a jar in the jre/lib/ext directory

antjarjava

I put "stax-utils.jar" in the extensions directory ([JAVA_HOME]/jre/lib/ext), but ant's java task can't find it, giving:

java.lang.NoClassDefFoundError: javanet/staxutils/IndentingXMLStreamWriter

Strangely, it works for compilation: ant's javac task can find it. The problem is only with running code, with ant's java task…

  • If I use java from the command line, the jar is found and I can use classes from it.

  • If I explicitly give ant the classpath to that specific jar in the extension directory, it also works.

(I've seen this problem before, with one of the XML libraries.)

Best Answer

try adding it to ANT_HOME/lib

Related Topic