Results 1 to 5 of 5
  1. #1
    raghu9198's Avatar
    raghu9198 is offline Member
    Join Date
    Dec 2008
    Posts
    32
    Rep Power
    0

    Question Jar file creation

    Hello Everyone,
    I am trying to create a jar file and have succeeded in my attempt but I am unable to run it ..
    using
    jar cmf man.txt Chess.jar *.class command I can create a jar file but when try to run it using
    java -jar Chess.jar I am getting the following error


    Exception in thread "main" java.lang.NoClassDefFoundError: chess
    Caused by: java.lang.ClassNotFoundException: chess
    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: chess . Program will exit.



    and infact I can't run by clicking on it
    I have attached the manifest file. Please check it


    Please help:confused:

    Thanks ,
    raghu
    Attached Files Attached Files

  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
    19

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Quote Originally Posted by raghu9198 View Post
    and infact I can't run by clicking on it
    Use the "e" option when you package it.

  4. #4
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    The class "chess" (it should be "Chess") must listed in the manifest, or java wouldn't know to look for it.

    Try

    java -cp Chess.jar -jar Chess.jar

    I think it is a classpath issue...

    Also, you can try

    java chess

    if you set the classpath before executing java, which would verify that the class is in the JAR.

    Come to think of it, the class is probably named "Chess", and you failed to capitalize it when you created the attribute in the manifest.
    Last edited by Steve11235; 01-11-2009 at 02:33 AM. Reason: and...

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

Similar Threads

  1. bmp creation
    By makpandian in forum New To Java
    Replies: 1
    Last Post: 12-17-2008, 05:33 PM
  2. Executable Jar File Creation
    By Doctor Cactus in forum New To Java
    Replies: 7
    Last Post: 11-13-2008, 03:31 AM
  3. Java GUI creation help?
    By sabrown311313 in forum New To Java
    Replies: 4
    Last Post: 09-13-2008, 06:28 AM
  4. How to print the creation date of a jar file
    By lunarbof in forum Advanced Java
    Replies: 9
    Last Post: 08-22-2008, 06:12 PM
  5. An Introduction to Eclipse PDE - File Creation
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-09-2007, 06:40 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
  •