wood burning stoves
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant's junittask and classnotfound exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant Watch "Ant New topic

Ant's junittask and classnotfound exception

Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Hello, i'm calling and Ant script from a Java program, this is a piece of code of the AntCaller class
So after that, every target in the project gets executed, but the junit target that generates a report is saying that the tests failed
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
. The strange thing is that the same script called from the command line works great, but I need to be able to call it from within the java program. What can i do?
Peter Johnson

Joined: May 14, 2008
Posts: 5852

When you run Ant from the command line, it automatically includes every JAR file in the ant_home/lib directory in the classpath. This is in addition to the directories and JARs specified in the classpath property of any given Ant task. Because you are getting a ClassNotFoundException, you are missing one of those JARs or directories in your classpath. Unfortunately, I have no idea where class 'xxx' is located (I assume you replaced the actual class name with 'xxx').

JBoss In Action
I agree. Here's the link: http://aspose.com/file-tools
subject: Ant's junittask and classnotfound exception
It's not a secret anymore!