[Advanced-java] JarClassLoader problem

Gianfranco Alongi gianfranco.alongi at witsbits.com
Wed Jul 2 22:45:17 PDT 2008


Hi there!

I am using the JarClassLoader [
http://www.jdotsoft.com/JarClassLoader.php ]class to
bundle my project into one jar.

I am having difficulties with getting this to work, I followed the
described steps on the page, made the steps by hand (I am using a
buildscript for the moment),
but didn't get it to work. The problem is that the JarClassLoader does not
seem to find the
Launcher class.

i) I have checked that the manifest contains the Main-Class:
source.Launcher entry
ii) I have checked that the Launcher class indeed is within the
source/ catalog inside the jar
iii) All compilations go without a problem
iv) All used source files have their respective packages correctly defined

This is the error I receive when running the jar

> java -jar wc3.jar --help

Exception in thread "main" java.lang.NoClassDefFoundError: source/Launcher
Caused by: java.lang.ClassNotFoundException: source.Launcher
       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)


This is how the main jar looks like when listed

    0 Thu Jul 03 07:26:42 CEST 2008 META-INF/
  101 Thu Jul 03 07:26:44 CEST 2008 META-INF/MANIFEST.MF
 9087 Thu Jul 03 07:26:40 CEST 2008 source/Executor.class
 9811 Thu Jul 03 07:26:40 CEST 2008 source/Parser.class
 1673 Thu Jul 03 07:26:40 CEST 2008 source/Passport.class
 1260 Thu Jul 03 07:26:40 CEST 2008 source/Prettyprinter$Config.class
 6097 Thu Jul 03 07:26:40 CEST 2008 source/Prettyprinter.class
 4967 Thu Jul 03 07:26:40 CEST 2008 source/WC3.class
    0 Thu Jul 03 07:26:38 CEST 2008 Libs/
 23563 Thu Jul 03 07:26:38 CEST 2008 Libs/saxpath.jar
305545 Thu Jul 03 07:26:38 CEST 2008 Libs/commons-httpclient.jar
153115 Thu Jul 03 07:26:38 CEST 2008 Libs/jdom.jar
124724 Thu Jul 03 07:26:38 CEST 2008 Libs/jaxp-1.3.jar
174833 Thu Jul 03 07:26:38 CEST 2008 Libs/jakarta-slide-webdavlib-2.1.jar
 51273 Thu Jul 03 07:26:38 CEST 2008 Libs/commons-logging-1.1.jar
 5881 Thu Jul 03 07:26:38 CEST 2008 Libs/jaxen-jdom.jar
 46725 Thu Jul 03 07:26:38 CEST 2008 Libs/commons-codec-1.3.jar
305545 Thu Jul 03 07:26:38 CEST 2008 Libs/commons-httpclient-3.1.jar
 69344 Thu Jul 03 07:26:38 CEST 2008 Libs/JSAP-2.1.jar
109043 Thu Jul 03 07:26:38 CEST 2008 Libs/commons-io-1.4.jar
160967 Thu Jul 03 07:26:38 CEST 2008 Libs/jaxen-core.jar
  564 Thu Jul 03 07:26:40 CEST 2008
com/jdotsoft/jarloader/JarClassLoader$1.class
 1305 Thu Jul 03 07:26:40 CEST 2008
com/jdotsoft/jarloader/JarClassLoader$2.class
 1117 Thu Jul 03 07:26:40 CEST 2008
com/jdotsoft/jarloader/JarClassLoader$JarClassLoaderException.class
 1288 Thu Jul 03 07:26:40 CEST 2008
com/jdotsoft/jarloader/JarClassLoader$JarEntryInfo.class
 13600 Thu Jul 03 07:26:40 CEST 2008com/jdotsoft/jarloader/JarClassLoader.class
  574 Thu Jul 03 07:26:44 CEST 2008 source/Launcher.class


However, the main jar is executable when explicitly using the launcher

> java -cp wc3.jar source.Launcher --help

Usage: java -jar source.WC3.jar --help
{and a long usage description....}

When I extract the MANIFEST and examine it, it contains

zenon at matrix:~/Java/WC3/Build/temp/META-INF$ cat MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.6.0_06 (Sun Microsystems Inc.)
Main-Class: source.Launcher

(with trailing newline)


So, conclusively.
Everything compiles fine, I followed the instructions, it works if
source.Launcher is given, does NOT work when
trying > javar -jar wc3.jar

Do you have an idea what my problem is?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /lists/advanced-java/attachments/20080703/a0949f0f/attachment.html 


More information about the Advanced-java mailing list