Results 1 to 3 of 3
  1. #1
    TannerLD is offline Member
    Join Date
    Sep 2009
    Posts
    5
    Rep Power
    0

    Default Running Jar File - NoClassDefFoundError

    Hi all,

    This error has been annoying me for a while and has stopped me from running any and all jar files I create or found, but is mostly annoying as I can't create my own nor run them.

    My code works fine in Eclipse, running is smooth, nothing bad happens or explodes. Though if I Export -> Runnable Jar File, the Jar doesn't do anything but complain:

    Java Code:
    Macbook:Desktop tanner$ java ./Find\ Music\ on\ Bigg\ HDD.jar 
    Exception in thread "main" java.lang.NoClassDefFoundError: //Find Music on Bigg HDD/jar
    Caused by: java.lang.ClassNotFoundException: ..Find Music on Bigg HDD.jar
    	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:319)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)
    I've done endless searches on Google for this so I know it has something to do with a ClassPath variable that either the project or the computer will hold, but no idea what to set it to or how.

    Anyone know anything about this?

    Thanks
    -Tanner

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    a jar is not a class. a jar is just an archive containing classes. you have to run the java command on the class with the main method.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,016
    Rep Power
    20

    Default

    Quote Originally Posted by TannerLD View Post
    Hi all,

    This error has been annoying me for a while and has stopped me from running any and all jar files I create or found, but is mostly annoying as I can't create my own nor run them.

    My code works fine in Eclipse, running is smooth, nothing bad happens or explodes. Though if I Export -> Runnable Jar File, the Jar doesn't do anything but complain:

    Java Code:
    Macbook:Desktop tanner$ java ./Find\ Music\ on\ Bigg\ HDD.jar 
    Exception in thread "main" java.lang.NoClassDefFoundError: //Find Music on Bigg HDD/jar
    Caused by: java.lang.ClassNotFoundException: ..Find Music on Bigg HDD.jar
    	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:319)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)
    I've done endless searches on Google for this so I know it has something to do with a ClassPath variable that either the project or the computer will hold, but no idea what to set it to or how.

    Anyone know anything about this?

    Thanks
    -Tanner
    Is this an executable jar? That is, is there a class in there with a main() method, and a manifest file which references that class?

    If so, then "java -jar <jarfile> <any arguments your class needs>".

Similar Threads

  1. Replies: 0
    Last Post: 08-26-2009, 01:03 PM
  2. Problems getting jar file running locally
    By edpfister in forum Java Applets
    Replies: 2
    Last Post: 03-09-2009, 08:01 PM
  3. Replies: 2
    Last Post: 03-09-2009, 02:36 AM
  4. error while running jar file
    By ernieBob in forum NetBeans
    Replies: 1
    Last Post: 03-25-2008, 11:13 AM
  5. Replies: 7
    Last Post: 08-12-2007, 03:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •