Results 1 to 15 of 15
  1. #1
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default [SOLVED] Jar file wont run but runs in netbeans

    Hi all,
    I have a program that runs in netbeans but the jar file doesn't run.
    Can anyone please help... I have included the link to the project folder:

    http://dl.dropbox.com/u/6917833/layo...emoProject.zip
    Last edited by ArmenBaba; 08-23-2010 at 11:28 AM.

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

  3. #3
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    Yes I apologize,
    When I double-click the built .jar file located in the dist folder, I get the following error message.
    failed to load main-class manifest attribute
    I googled it and I found a solution to add a manifest.mf file to the project and follow a few more steps which allowed the program no to produce the error message however, when I double click noting happens.
    -Thank you for the reply
    Last edited by ArmenBaba; 08-23-2010 at 08:12 AM.

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

    Default

    That's because in NetBeans you don't have define the main class before build the project. NetBeans not execute the project through the IDE suing JAR files, used the *.class files. That's why your application is executed properly in NetBeans.

    Right click on the project and click properties. Then define the main class in Run section of the dialog.

  5. #5
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    Yes I've done that sorry I should've reported all the steps I've taken.
    I do have several main classes defined though but I'm sure I've chosen the correct main class for the run argument.
    thank you again for replying.

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

  7. #7
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    You misunderstood me I've did that already but the program won't run. It's not even visible as part of my processes.

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

    Default

    Oh, I thought you've solve the problem. Did you define the main class properly?

    If so extract the JAR file and check the manifest file content.

  9. #9
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    Ok I figured out a way how to fix the problem.
    Since I was double clicking on the jar file from a windows environment, I couldn't figure out the problem, but when I ran the program form cmd using java -jar, I saw I had null pointer exception thrown without handling. Thus running your program from cmd, will output the problem.

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

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    It's possible if it's some resource (ie properties file) that hasn't been copied into the jar, so it would work in Netbeans but not through the jar.

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

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default

    He doesn't mention much at all, to be honest....but that's one of the more common ways for getting an NPE in a jar when it worked fine in the IDE.

  14. #14
    ArmenBaba is offline Member
    Join Date
    Aug 2010
    Posts
    9
    Rep Power
    0

    Default

    I apologize I forgot to explain in details.
    I use several directories in my program and I didn't copy them in the dist folder where the .jar file was running from. Also when running from the cmd, you must travel to the dist directory and run the jar file from there where the folders are located.

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

Similar Threads

  1. button that runs away from the mouse cursor
    By MartinBenes71 in forum New To Java
    Replies: 1
    Last Post: 01-28-2010, 09:00 AM
  2. Replies: 0
    Last Post: 10-04-2009, 03:47 PM
  3. [SOLVED] App runs only in IDE
    By hannehomuth in forum Advanced Java
    Replies: 4
    Last Post: 07-15-2009, 07:41 PM
  4. Opening file, runs in NetBeans but CommandPrompt
    By fauzilhaqqi in forum NetBeans
    Replies: 2
    Last Post: 12-15-2008, 04:48 AM
  5. Program Runs in NetBEans but Not in cmd
    By MeathUltra in forum NetBeans
    Replies: 1
    Last Post: 12-09-2008, 06:38 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
  •