I built an executable jar using an ant script, the only external jar I used was joda-time 2.0. The ant build script “seemed” to work as I did not recieve any compile errors, and if I were to remove the jode-time 2.0.jar from the lib directory the build would indeed fail as expected. At any rate, after building the jar I get this error when I try to run with:
java -jar myapp.jar
Exception in thread “main” java.lang.NoClassDefFoundError: org/joda/time/ReadableInstant
Any thoughts on this? I’m just not sure where to look, everything works just fine within Eclipse. thanks for any ideas
Presumably, your jar doesn’t contain a manifest header telling Java to add the joda-time jar to the classpath. That’s the only way to have other classpath entries when using
java -jar. You could do this directly with the Ant manifest task, or there are probably multiple other ways to do it, including building it from your existing classpath.Alternately, try