4 Replies Latest reply on Oct 15, 2008 10:38 PM by 843804

    can't run jar file

    843804
      Hi All,

      I've written small application in Java3D. I packed all the class and Java3D's dll's into jar file.
      when I run the jar file from command line via java -jar Load3DModel.jar I get the following (Load3DModel is my main class name and project name):

      "Exception in thread "main" java.lang.NoClassDefFoundError: (wrong name: loading3dmodels/Load3DModel)
      at java.lang.ClassLoader.defineClass1(Native Method)
      ......
      ....."


      The MANIFEST.MF file is as follows:
      Manifest-Version: 1.0
      Class-Path: vecmath.jar j3dutils.jar j3dcore.jar
      Created-By: 1.6.0_06 (Sun Microsystems Inc.)
      Main-Class: Load3DModel

      I don't see the problen. please help me
      Thank in advance
      Eyal
        • 1. Re: can't run jar file
          800560
          JAddicted wrote:
          "Exception in thread "main" java.lang.NoClassDefFoundError: (wrong name: loading3dmodels/Load3DModel)
          at java.lang.ClassLoader.defineClass1(Native Method)

          The MANIFEST.MF file is as follows:
          Manifest-Version: 1.0
          Class-Path: vecmath.jar j3dutils.jar j3dcore.jar
          Created-By: 1.6.0_06 (Sun Microsystems Inc.)
          Main-Class: Load3DModel
          Your manifest says the main class is named Load3DModel, but the class in the jar is named loading3dmodels.Load3DModel. Obviously this is the "wrong name." Looks like your main class is in a package named loading3dmodels. So that needs to be part of the class name and you need to jar the .class file so it is in a loading3dmodels directory.

          I think you should always get your code running before jar'ing it. Then you know how to specify your Main-Class and what classes are needed in the Class-Path. If you try running your un-jar'ed code, you will either have the same error or you will be specifying a different main class.
          • 2. Re: can't run jar file
            843804
            I did check that the program work within the IDE (NetBeans in this case)
            since I create the jar where all the .class are in , I don't really have any packages I mean I have one package and I bulit the jar within that package (or folder).
            I treid to rename the Main-Class in the MANIFEST file - still get the same exception.
            • 3. Re: can't run jar file
              800560
              JAddicted wrote:
              I did check that the program work within the IDE (NetBeans in this case)
              since I create the jar where all the .class are in , I don't really have any packages I mean I have one package and I bulit the jar within that package (or folder).
              I treid to rename the Main-Class in the MANIFEST file - still get the same exception.
              Do you mean that you changed the mainifest so it says "Main-Class: loading3dmodels.Load3DModel" and you still get the exact same error? I find that hard to believe.

              Sorry, I can't help you with NetBeans.
              • 4. Re: can't run jar file
                843804
                When I use external .dll's I don´t pack them with the jar application. I just keep them in the same directory. Other way it doesnt work. The same to external jar libraries.