Results 1 to 7 of 7
  1. #1
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Thumbs down Creating JAR file goes wrong.

    I have created a jar file, at first there was some error about no main, so I added a manifest. Now I get this error, but I cannot figure out what it means.

    C:\>java -jar img.jar

    Exception in thread "main" java.lang.NoClassDefFoundError: image$Mode
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.ja va:2427)
    at java.lang.Class.getDeclaredMethod(Class.java:1935)
    at java.awt.Component.isCoalesceEventsOverriden(Compo nent.java:5948)
    at java.awt.Component.access$500(Component.java:169)
    at java.awt.Component$3.run(Component.java:5902)
    at java.awt.Component$3.run(Component.java:5900)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Component.checkCoalescing(Component.java: 5899)
    at java.awt.Component.<init>(Component.java:5868)
    at java.awt.Container.<init>(Container.java:251)
    at java.awt.Panel.<init>(Panel.java:48)
    at java.awt.Panel.<init>(Panel.java:40)
    at java.applet.Applet.<init>(Applet.java:48)
    at image.<init>(image.java:42)
    at image.main(image.java:238)
    Caused by: java.lang.ClassNotFoundException: image$Mode
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 07)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:2 52)
    at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:320)

    Some help please? :)

  2. #2
    AlbertoPL is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default

    Check your manifest, did you accidentally put a space in your Class imageMode?

    (like this: image Mode)

    Also I highly recommend capitalizing the first letter of your classes, it's a good convention to follow.

    A post showing what your manifest looks like and the classes you have in your jar would be helpful.

  3. #3
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Default

    I only have one class in the jar file, it is called image.class so there are no spaces.

    The manifest is like this:
    Manifest-Version: 1.0
    Main-Class: image


    And if I remember correctly the jar creating I did was like this:

    jar cvfm image.jar manifest.mf image.class

  4. #4
    AlbertoPL is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default

    I will assume then that your image.java has the class name as image? If not, the problem lies there.

    The jar itself looks ok. Are you sure you aren't missing any other classes that you might need?

  5. #5
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Default

    class name image? you mean the class file is called image.class? yes.

  6. #6
    AlbertoPL is offline Member
    Join Date
    Sep 2009
    Posts
    22
    Rep Power
    0

    Default

    No, I am referring to the actual source, the image.java file should have this line:

    public class image {

    }

    If that is not the case, that would be the cause of the error. The error itself states that it cannot find the class image$Mode. That leads me to believe that either the image$Mode.class file is missing, or the image.class file should be named image$Mode.

    If you do not have the image.java file, then I would try renaming the image.class file to image$Mode and see if that does anything.

  7. #7
    dudejonne is offline Member
    Join Date
    Oct 2009
    Posts
    56
    Rep Power
    0

    Default

    Ahh.. I remember when I did that javac image.java there were some extra files created... wait..
    Yap.. I added that image$Mode and three others and it works! Thnx!

Similar Threads

  1. Creating a .jar file
    By Wataru in forum New To Java
    Replies: 3
    Last Post: 07-22-2009, 06:02 AM
  2. Creating jar file
    By Heather in forum Advanced Java
    Replies: 4
    Last Post: 02-11-2009, 09:58 AM
  3. Replies: 1
    Last Post: 05-30-2008, 10:33 PM
  4. creating jar file
    By po0oker in forum Advanced Java
    Replies: 3
    Last Post: 04-04-2008, 07:49 PM
  5. creating .ear file
    By psn in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 01-06-2008, 05:01 AM

Posting Permissions

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