Results 1 to 13 of 13
  1. #1
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default JAR Building Problem

    um having problem in creating .jar for a project...i use Netbeans 6 IDE... i had no problem with the last project but this project gives me a main class not found error...i manually edited the manifest.mf file and compiled another .jar file but that gives me the same problem...i dont know what to do...this is the link to the project folder...can any one help me finding the problem??

    link to the project:
    filefactory.com/file/0ef240/n/TenderManagementSystem_rar

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    project gives me a main class not found error
    How/What command do you issue to get the above error?
    Can you post the full text of the error message?
    Can you get to a commandprompt and enter:
    java -jar <jarname>
    What is in the manifest file in the jar file?

    It should work if the jar file is found by the java command and the manifest file in the jar file has a Main-class: entry and the class pointed to by that entry is in the jar file with the correct package path.

  3. #3
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    the full error text is:
    could not find the main class. program will exit.

    my manifest file is:
    Manifest-Version: 1.2
    Ant-Version: Apache Ant 1.7.0
    Created-By: 1.4 (Sun Microsystems Inc.)
    Main-Class: IndexFrame
    Class-Path: lib/swingx-0.9.3.jar lib/AbsoluteLayout.jar lib/mysql-connector-java-5.1.6-bin.jar


    output of the command java -jar "tendermanagementsystem.jar":
    Exception in thread "main" java.lang.NoClassDefFoundError: IndexFrame
    Caused by: java.lang.ClassNotFoundException: IndexFrame
    at java.net.URClassLoader$1.run...........
    .................................................. .......
    .................................................. .......

    can u please download and try building the jar...???
    Last edited by GhosT; 09-25-2008 at 06:44 PM.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    class pointed to by that entry is in the jar file with the correct package path.
    Look inside the jar file at the IndexFrame entry. It shouldn't be on any path. Is IndexFrame in a package? If so, the Main-Class: entry must include it.
    ................................................. .......
    .................................................. .......
    Please don't edit the error message. There many be relevant info in it.

    download and try building the jar
    Sorry, I can't read rar files and I don't use an IDE.

  5. #5
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    class IndexFrame is in the jar file under tendermanagementsystem/IndexFrame.class, theres also an image folder. If i extract the jar i get 3 folders.

    1. images
    2. META-INFO (manifest.mf)
    3. TenderManagementSystem (Contains *.class)

    IndexFrame.class is there along with IndexFrame$1.class to IndexFrame$90.class files.

    Previously i used jdk 6 update 1 and i was able to run jars only using a batch file, but double clicking didnt work...i updated to jdk 6 update 7 and changed the environment variables to match new jdk. now batch files also dont work...strange...

    some other projects run fine...i just double click the jar ...tada.....but this project and another one just dont listen to me...:S

    any help??

    i suggest u to please compile/build and run the project using netbeans 6 IDE...thn u might find the problem...

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    Is IndexFrame in a package? If so, the Main-Class: entry must include it.
    Main-Class: IndexFrame
    tendermanagementsystem/IndexFrame.class
    Change the Main-class: to include the package-path
    suggest u to please compile/build and run the project using netbeans 6 IDE.
    I don't use an IDE.

  7. #7
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    i did but its all the same...manual build reduce the size of jar from 373KB (provided by netbeans) to 168KB...

    i located the main class in the manifest and built
    jar cfm manifest.mf tms.jar *.class

    still same...

    i need help from someone used to with netbeans...bacause that way i'll understand better...um a noob in java :D

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    What does the Main-class: entry in your manifest look like now?
    Your earlier post showed it was wrong if your class is in a package.
    It must have the package-path with the classname:
    Main-class: <package>.<classname>

  9. #9
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    Manifest-Version: 1.2
    Ant-Version: Apache Ant 1.7.0
    Created-By: 1.4 (Sun Microsystems Inc.)
    Main-class: TenderManagementSystem.IndexFrame
    Class-Path: lib/swingx-0.9.3.jar lib/AbsoluteLayout.jar lib/mysql-connector-java-5.1.6-bin.jar

    i extracted the netbeans generated jar and changed the main class entry of the .mf file thn i manually rebuild the jar from the extracted archive...

    now the problem is if i manually build the jar, its size reduces and doesn't work , i told u before...and the netbeans generated jar don't have the package name in the manifest main class entry....

    is there any other way to build jar other thn this command?
    jar cmf manifest.mf jarfile.jar components

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,607
    Rep Power
    23

    Default

    doesn't work
    Please post the full text of error messages.
    Java is case sensitive. In one place you posted:
    tendermanagementsystem/IndexFrame.class
    then in the manifest you show:
    Main-class: TenderManagementSystem.IndexFrame

    If they refer to the same class, they MUST be spelled the same way.
    Look at the contents of the jar file generated by netbeans and compare that to the one that you generate manually. What files extra files are included in the larger one.

    Your jar command syntax looks ok. The thing I can't check is whether the "components" part is write.

    I have a program that will look in a jar file and check for some of the errors you are having. Open the jar file, Choose the jarfile, it should load the Class name field if it finds a manifest and press
    Search. The program reads the class files in the jar looking for the starting class and for all classes reference by that class:
    http://shellknob2007.googlepages.com/CheckClassRefs.jar

  11. #11
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    #Searching C:\Documents and Settings\Others\My Documents\NetBeansProjects\TenderManagementSystem\ dist\TenderManagementSystem.jar for IndexFrame
    IndexFrame >>>> class NOT found! <<<<

    # Found 1 classes. 1 NOT found.

    at first its automatically loading IndexFrame in the class field...later its telling that class not found....
    and the class its loading has no package informations...

  12. #12
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    oohh...finally it worked...here are the steps.
    1. Extracted the damaged JAR in a folder named TenderManagementSystem.
    It contains 3 folder:
    - images (images)
    - META-INF (manifest)
    - tendermanagementsystem (classes)
    2. Added Package Info in the META-INF/MANIFEST.MF file main class entry.
    Main-class: <package>.<classname>
    3. Cut the MANIFEST.MF file and paste it outside the META-INF folder.
    3. Windows -> Run -> cmd
    4. cd ExtractedFolder
    5. jar cmf MANIFEST.MF TMS.JAR tendermanagementsystem images

    it resulted into a TMS.JAR which is working just fine... :D

    thanx to Norm...u r a good teacher and u didnt loose your temper when i wasnt successful. i will keep in touch with ya.

    thanx again.

  13. #13
    GhosT's Avatar
    GhosT is offline Member
    Join Date
    Sep 2008
    Location
    Dhaka, Bangladesh
    Posts
    37
    Rep Power
    0

    Default

    do u know any good resource for making exe from jar other thn jsmooth...please dont post sharewares...

Similar Threads

  1. Problem with String Building
    By Albert in forum New To Java
    Replies: 2
    Last Post: 04-30-2012, 12:49 AM
  2. Replies: 15
    Last Post: 09-30-2008, 03:50 AM
  3. help needed regarding tree building
    By invincible_me in forum New To Java
    Replies: 2
    Last Post: 08-12-2008, 01:44 PM
  4. building a house
    By dc2acgsr99 in forum Java Applets
    Replies: 4
    Last Post: 03-07-2008, 11:18 PM
  5. Building a document from a DOM
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-03-2008, 09:22 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
  •