Results 1 to 4 of 4
  1. #1
    VeasMKII's Avatar
    VeasMKII is offline Member
    Join Date
    Jan 2009
    Posts
    18
    Rep Power
    0

    Default [SOLVED] Error executing Jar file

    When i try to run (by double clicking) my .jar file i get the following:

    Java Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: C:\Users\VeasMKII\Doc
    uments\NetBeansProjects\Tray\dist\PPPU/jar
    Caused by: java.lang.ClassNotFoundException: C:\Users\VeasMKII\Documents\NetBean
    sProjects\Tray\dist\PPPU.jar
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Could not find the main class: C:\Users\VeasMKII\Documents\NetBeansProjects\Tray
    \dist\PPPU.jar.  Program will exit.
    I think this is related to my use and import of
    Java Code:
    import java.net.URL;
    which i use to read resources from certain directories.
    *edit*
    Can't be related to this. Rebuilt and cleaned with this code and import omitted, same error.

    Other than that I actually have no idea why this is the case, can anyone shed any light on this? I've finished my program but unfortunately i can't distribute it like this :)
    Last edited by VeasMKII; 01-29-2009 at 03:23 PM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Are you build this jar file on NetBeans? If so can you run this application successfully on NetBeans?

  3. #3
    VeasMKII's Avatar
    VeasMKII is offline Member
    Join Date
    Jan 2009
    Posts
    18
    Rep Power
    0

    Default

    I really can't say for sure how I fixed this or what the problem was.

    Its solved now though. But it was a major headache, i think it had something to do with using the JDK/JRE 64bit because it worked when i reinstalled to the 32-bit versions.

    I coupled this with a combination of things, like trying Eclipse to export runnable jar files instead of using NetBeans and playing with the PATH environmental variables.

    The jar documentation is pretty poor when it comes down to creating a proper MANIFEST.MF.

    But now i'm left with the annoying catch22 problem of reading the resources from inside my Jar

    Java Code:
        static TrayIcon trayIcon = new TrayIcon(createImage
                ("/images/Grey.png",     "Grey"));
    How would i redirect this to the jar file? Keeping in mind that using class().getResource wont work on static objects and TrayIcon (seems) to need to be static in order to work.

    I hate it when the problem shifts so much from the orginal ;)
    Last edited by VeasMKII; 01-30-2009 at 04:25 PM.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I'm not clear what you exactly going to do. If I'm correct you are going to use some methods in an external package which you are talking about here. So in that case you have to clearly findout what are the accessible methods, public methods basically. Get set methods.....

Similar Threads

  1. Executing a jar file
    By peiceonly in forum New To Java
    Replies: 7
    Last Post: 02-14-2014, 10:02 AM
  2. Error Occurred Executing Command Line Solution
    By RahulKhire in forum Eclipse
    Replies: 1
    Last Post: 09-10-2008, 02:38 PM
  3. Error When Executing Query
    By radz in forum New To Java
    Replies: 5
    Last Post: 06-26-2008, 04:37 AM
  4. reading from a zip file, error
    By Mr tuition in forum AWT / Swing
    Replies: 1
    Last Post: 01-16-2008, 01:39 AM
  5. executing the java file
    By TheBayWatchMan in forum New To Java
    Replies: 4
    Last Post: 01-12-2008, 10:31 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
  •