Results 1 to 4 of 4
  1. #1
    abhijit is offline Member
    Join Date
    Sep 2009
    Rep Power

    Post main class not found

    i want to develop jar file of my application..

    i have set the main class of jar file in Manifest.txt file
    I have created a jar file using command:

    jar cf Bluetooth.jar Manifest.txt javaapplication10.Bluetooth.class

    (javaapplication10) is the name of package..

    after this when i try to execute the jar file using command:
    >>java -jar Bluetooth.jar

    it is throwing the exception as:
    NoClassDefination Found

    please let me know what is problem with this.
    is i'm missing any step of jar creation?

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    quite possibly the class you have placed into the jar file has a dependency on another class that is not included into the jar file.

    For example, if I create a jar file that depends on the commons-logging or log4j (has a local reference to the logger component) then my classpath needs to include those third party jar files.

    For the jar to run with java -jar, in addition to specifying the Main-Class attribute, you can also set a Class-Path attribute, which should be a relative path to the location of the other dependent jar files.

    See also: Adding Classes to the JAR File's Classpath (The Java™ Tutorials > Deployment > Packaging Programs in JAR Files)

  3. #3
    abhijit is offline Member
    Join Date
    Sep 2009
    Rep Power


    Thank u very much 4 ur help.
    but i'm still having the same problem.
    Now I'm having two text files viz., Manifest.txt and Manifest1.txt

    contents of Manifest.txt are:
    Main-Class: BluetoothServiceDiscovery.class

    contents of Manifest1.txt are:
    Class-Path: avetanaObex.jar bluecove.jar BlueCoveJSR82.jar

    now i've created the jar file using the following command
    jar cfv blue.jar Manifest.txt Manifest1.txt BluetoothServiceDiscovery.class

    it is creating the jar file giving the following o/p on command prompt:
    added manifest
    adding: Manifest.txt(in = 59) (out= 46)(deflated 22%)
    adding: Manifest1.txt(in = 60) (out= 54)(deflated 10%)
    adding: BluetoothServiceDiscovery.class(in = 11342) (out= 5852)(deflated 48%)

    but when i try to run the blue.jar file using following command:
    java -jar blue.jar

    it's showing the same error:
    Failed to load Main-Class manifest attribute from blue.jar

    Please let me know what is problem?

  4. #4
    abhijit is offline Member
    Join Date
    Sep 2009
    Rep Power


    Hi , thank u again 4ur concern.
    I got the solution for the same problem ,
    now my application is working properly.

Similar Threads

  1. No Class Def Found Error:
    By fithous in forum Java Applets
    Replies: 0
    Last Post: 04-02-2009, 05:30 PM
  2. No main class found error
    By jhering1986 in forum New To Java
    Replies: 17
    Last Post: 03-28-2009, 03:34 AM
  3. Replies: 4
    Last Post: 01-01-2009, 04:58 AM
  4. Replies: 12
    Last Post: 12-05-2008, 06:37 AM
  5. No Class Def Found Error:
    By wrap23 in forum New To Java
    Replies: 9
    Last Post: 10-02-2008, 04:07 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