Exception in thread "main" java.lang.NoClassDefFoundError

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmitch89
    New Member
    • Sep 2008
    • 3

    Exception in thread "main" java.lang.NoClassDefFoundError

    I don't why I get this error:
    Exception in thread "main" java.lang.NoCla ssDefFoundError

    The statement below works just fine:
    java -cp "appframewo rk-1.0.3.jar;swing-worker-1.1.jar";Curren tStrobe.jar com.visionpro.c urrentstrobe.Cu rrentStrobeApp

    However, the statement below produces the error:
    java -cp "appframewo rk-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.j ar

    Exception in thread "main" java.lang.NoCla ssDefFoundError : org/jdesktop/application/SingleFrameAppl ication
    at java.lang.Class Loader.defineCl ass1(Native Method)
    at java.lang.Class Loader.defineCl ass(Unknown Source)
    at java.security.S ecureClassLoade r.defineClass(U nknown Source)
    at java.net.URLCla ssLoader.define Class(Unknown Source)
    at java.net.URLCla ssLoader.access $000(Unknown Source)
    at java.net.URLCla ssLoader$1.run( Unknown Source)
    at java.security.A ccessController .doPrivileged(N ative Method)
    at java.net.URLCla ssLoader.findCl ass(Unknown Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at sun.misc.Launch er$AppClassLoad er.loadClass(Un known Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at java.lang.Class Loader.loadClas sInternal(Unkno wn Source)
    Caused by: java.lang.Class NotFoundExcepti on:org.jdesktop .application.Si ngleFrameApplic ation
    at java.net.URLCla ssLoader$1.run( Unknown Source)
    at java.security.A ccessController .doPrivileged(N ative Method)
    at java.net.URLCla ssLoader.findCl ass(Unknown Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at sun.misc.Launch er$AppClassLoad er.loadClass(Un known Source)
    at java.lang.Class Loader.loadClas s(Unknown Source)
    at java.lang.Class Loader.loadClas sInternal(Unkno wn Source)
    ... 12 more
    Could not find the main class: com.visionpro.c urrentstrobe.Cu rrentStrobeApp. Program will exit.

    Any ideas?
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    I've also encountered that one before,

    What i did is i've set the classpath inside the Manifest file instead of doing like what you did in the commandline.

    try it

    Comment

    • jmitch89
      New Member
      • Sep 2008
      • 3

      #3
      I was thinking of doing that.

      I just wonder why this happens. I've used this syntax before without any problems. I'm sure it's a classpath issue but I don't know why it happens.

      They say ignorance is bliss but I hate not understanding why.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by jmitch89
        I don't why I get this error:
        Exception in thread "main" java.lang.NoCla ssDefFoundError

        The statement below works just fine:
        java -cp "appframewo rk-1.0.3.jar;swing-worker-1.1.jar";Curren tStrobe.jar com.visionpro.c urrentstrobe.Cu rrentStrobeApp

        However, the statement below produces the error:
        java -cp "appframewo rk-1.0.3.jar;swing-worker-1.1.jar" -jar CurrentStrobe.j ar

        Exception in thread "main" java.lang.NoCla ssDefFoundError : org/jdesktop/application/SingleFrameAppl ication

        Any ideas?
        In the first version you supply the class where the main() method is to be found:
        in class com.visionpro.c urrentstrobe.Cu rrentStrobeApp

        In the second version your jar tells the JVM to look for the class
        org/jdesktop/application/SingleFrameAppl ication which can not be found by the
        JVM. Fix the manifest in in the CurrentStrobe.j ar.

        kind regards,

        Jos

        Comment

        • jmitch89
          New Member
          • Sep 2008
          • 3

          #5
          The manifest inside the CurrentStrobe jar files read as follows:

          Manifest-Version: 1.0
          Ant-Version: Apache Ant 1.7.0
          Created-By: 10.0-b19 (Sun Microsystems Inc.)
          Main-Class: com.visionpro.c urrentstrobe.Cu rrentStrobeApp

          I added,

          Class-Path: appframework-1.0.3.jar swing-worker-1.1.jar

          and now it works just by issuing the following command:

          java -jar CurrentStrobe.j ar

          Thanks for the help...

          Comment

          Working...