This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am new to ant working on simple hello world app using ant...i am able to get to creating the jar....but unable to run cause it does not find the log4j.jar the code runs fine with the eclipse and the log4j is in classpath...but ant running jar does not find the log4j or any other jar files.
Buildfile: C:\Hello\Test\build.xml [echo] Hello, World clean: [delete] Deleting directory C:\Hello\Test\build compile: [mkdir] Created dir: C:\Hello\Test\build\classes [javac] Compiling 1 source file to C:\Hello\Test\build\classes jar: [mkdir] Created dir: C:\Hello\Test\build\jar [jar] Building jar: C:\Hello\Test\build\jar\HelloWorld.jar run: [java] java.lang.NoClassDefFoundError: org/apache/log4j/Logger [java] at us.Test.test.ant.HelloWorld.<clinit>(Unknown Source) [java] Exception in thread "main" [java] Java Result: 1 main: BUILD SUCCESSFUL Total time: 1 second
Ant expects all jar files in the lib directory inside the ANT_HOME directory. It does not use the standard classpath, so you should copy the required jar files to that directory. Alternatively, you could install those files systemwide (in the ...jre/lib/ext directory under Windows, e.g.).
Joined: Jul 03, 2004
Thanks Mr. Ulf Dittmer for your reply this is what i did to solve the problem