8 Replies Latest reply: Mar 17, 2010 9:45 PM by 843789 RSS

    Jar file won't run

    843789
      I get the following error message, I can provide more details on request. I just don't know what I can tell you. The first one is from trying to run the code from the src code the second is trying to run the JAR file in which I extracted the source code.
      Microsoft Windows XP [Version 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.
      
      C:\Documents and Settings\ToolWatcher>cd desktop
      
      C:\Documents and Settings\ToolWatcher\Desktop>cd gui
      
      C:\Documents and Settings\ToolWatcher\Desktop\GUI>java gui.GUI
      Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUI
      Caused by: java.lang.ClassNotFoundException: gui.GUI
              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: gui.GUI.  Program will exit.
      C:\Documents and Settings\ToolWatcher\Desktop>java -cp GUI.jar gui.GUi
      Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUi
      Caused by: java.lang.ClassNotFoundException: gui.GUi
              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: gui.GUi.  Program will exit.
        • 1. Re: Jar file won't run
          843789
          nndhawan wrote:
          I get the following error message, I can provide more details on request. I just don't know what I can tell you. The first one is from trying to run the code from the src
          You compile source code, not run it.
          code the second is trying to run the JAR file
          OK
          in which I extracted the source code.
          I don't understand.

          >
          Microsoft Windows XP [Version 5.1.2600]
          (C) Copyright 1985-2001 Microsoft Corp.
          
          C:\Documents and Settings\ToolWatcher>cd desktop
          
          C:\Documents and Settings\ToolWatcher\Desktop>cd gui
          
          C:\Documents and Settings\ToolWatcher\Desktop\GUI>java gui.GUI
          Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUI
          Caused by: java.lang.ClassNotFoundException: gui.GUI
          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: gui.GUI.  Program will exit.
          C:\Documents and Settings\ToolWatcher\Desktop>java -cp GUI.jar gui.GUi
          Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUi
          Caused by: java.lang.ClassNotFoundException: gui.GUi
          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: gui.GUi.  Program will exit.
          List the jar file and post the listing here. The 'jar' command documentation will tell you how to do that.
          Extract the manifest file from the jar file and post the content here.
          • 2. Re: Jar file won't run
            843789
            Sorry I meant I ran the bin file code (i.e. those with a .class extension). Once again sabre150 we meet again here is the manifest
            Class-Path: javabuilder.jar ProcessingLibraryV3.jar RXTXcomm.jar
            Main-Class: gui.GUI
            Microsoft Windows XP [Version 5.1.2600]
            (C) Copyright 1985-2001 Microsoft Corp.
            
            C:\Documents and Settings\ToolWatcher>cd Desktop
            
            C:\Documents and Settings\ToolWatcher\Desktop>jar tf GUI.jar
            META-INF/
            META-INF/MANIFEST.MF
            gui/
            gui/cameraImages/
            gui/cameraImages/50x1_6.bmp
            gui/cameraImages/50x1_6.jpg
            gui/cameraImages/temp/
            gui/cameraImages/temp/Thumbs.db
            gui/cameraImages/Thumbs.db
            gui/DemoGUI.class
            gui/ExecuteRunnable.class
            gui/Graph.class
            gui/GUI.class
            gui/GUIComponents.class
            gui/GUIEvent.class
            gui/GUIFunctions.class
            gui/GuiState.class
            gui/images/
            gui/images/.picasa.ini
            gui/images/.picasaoriginals/
            gui/images/.picasaoriginals/Thumbs.db
            gui/images/0023.JPG
            gui/images/DemoGUI.html
            gui/images/reload.jpg
            gui/images/temp.jpg
            gui/images/temp1.jpg
            gui/images/Thumbs.db
            gui/images/ToolDataChart.jpg
            gui/images/ToolWatcherIcon.JPG
            gui/javabuilder.jar
            gui/JNILibrary.class
            gui/LoadGUIImages.class
            gui/LoadImageApp$ZoomAndPanListener.class
            gui/LoadImageApp.class
            gui/macros/
            gui/macros/capture.au3
            gui/macros/capture.exe
            gui/macros/FIRSt.au3
            gui/macros/FIRSt.exe
            gui/macros/ledON_OFF.au3
            gui/macros/ledON_OFF.exe
            gui/macros/SECOND.au3
            gui/macros/SECOND.exe
            gui/MatlabWrapper.class
            gui/MicroControllerBox$Listener.class
            gui/MicroControllerBox.class
            gui/ProcessingLibraryV3.jar
            gui/SubPoint.class
            ImageSelection/
            ImageSelection/ImageSelection$ButtonListener.class
            ImageSelection/ImageSelection.class
            ImageSelection/LoadImageApp.class
            javabuilder.jar
            MANIFEST.txt
            ProcessingLibraryV3.jar
            RXTXcomm.jar
            rxtxSerial.dll
            SerialTest/
            SerialTest/CaptureImage.class
            SerialTest/LED_ON_OFF.class
            SerialTest/SerialTest.class
            • 3. Re: Jar file won't run
              843789
              Your listing shows that you have jars within jars. This does not work (though it can be made to work using special class loaders). Your Class-Path says that you have the 3 jars in the same directory as your jar GUI.jar. Are they?

              Why is your Class-Path referring to RXTXcomm.jar when (some of ?) the content of that jar are actually contained in GUI.jar ?
              • 4. Re: Jar file won't run
                800560
                nndhawan wrote:
                C:\Documents and Settings\ToolWatcher\Desktop>java -cp GUI.jar gui.GUi
                Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUi
                Caused by: java.lang.ClassNotFoundException: gui.GUi
                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: gui.GUi.  Program will exit.
                Just in case it is not a copy/paste problem, your class is named gui.GUI and in the above you typed gui.GUi which Java knows is not the same thing.
                • 5. Re: Jar file won't run
                  843789
                  atmguy wrote:
                  nndhawan wrote:
                  C:\Documents and Settings\ToolWatcher\Desktop>java -cp GUI.jar gui.GUi
                  Exception in thread "main" java.lang.NoClassDefFoundError: gui/GUi
                  Caused by: java.lang.ClassNotFoundException: gui.GUi
                  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: gui.GUi.  Program will exit.
                  Just in case it is not a copy/paste problem, your class is named gui.GUI and in the above you typed gui.GUi which Java knows is not the same thing.
                  I missed that and I also missed that he is not trying to run a jar file but to run a class in the jar file. Therefore his classpath (the -cp argument) must include ALL the jars he needs and not just GUI.jar.

                  I have a very strong "deja view" about this thread!
                  • 6. Re: Jar file won't run
                    800560
                    sabre150 wrote:
                    I missed that and I also missed that he is not trying to run a jar file but to run a class in the jar file. Therefore his classpath (the -cp argument) must include ALL the jars he needs and not just GUI.jar.
                    I didn't think about -cp and I didn't pay attention to the manifest. I think "java -jar GUI.jar" might actually work, assuming he has those dependent jars in the same directory as GUI.jar.
                    • 7. Re: Jar file won't run
                      843789
                      atmguy wrote:
                      sabre150 wrote:
                      I missed that and I also missed that he is not trying to run a jar file but to run a class in the jar file. Therefore his classpath (the -cp argument) must include ALL the jars he needs and not just GUI.jar.
                      I didn't think about -cp and I didn't pay attention to the manifest. I think "java -jar GUI.jar" might actually work, assuming he has those dependent jars in the same directory as GUI.jar.
                      The implication of the list of the jar content is that he has them enclosed in his GUI.jar and not in the same directory as the GUI.jar .
                      • 8. Re: Jar file won't run
                        843789
                        OMG SABRE150 thank you so much. I didn't realize the mistake I was making (not putting the jars in the same directory). I misread the tutorial god...I feel stupid. Thank you SOOOO MUCH!!! You have no idea the pain this has been causing me. I kept thinking to myself what in the freaking world could I be doing wrong, but I see why now. Geeezz finally I can put this to rest. Thanks again. If I could give you some duke star points I will, you deserve it. ::SIGH::