After several hours, I'm at my wit's end, even after reading reams of documentation and SO questions. I'm certain that I'm missing something obvious, but I just can't figure it out.
I've created a number of java files, including a single entry point with a main method. That class also makes use of one "library" class, located in com.test.lib.MyLibraryClass.class, within a jar file, mylib.jar. I'm building my jar file successfully using the following ant XML.
<target name="jar" depends="compile">
<jar destfile="${jar.dir}/${jar.name}.jar">
<fileset dir="${classes.dir}" />
<fileset dir="${lib.dir}" />
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Class-Path" value="mylib.jar"/>
</manifest>
</jar>
</target>
When I inspect the jar created by executing that target, I see that it does contain all of my .class files as well as mylib.jar.
When I try to run the jar however, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/test/lib/MyLibraryClass
at com.mytest.MyMain.<init>(Unknown Source)
at com.mytest.MyMain.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.test.lib.MyLibraryClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
What do I need to change? Am I generating a malformed or incomplete manifest?
Thank you so much!