Results 1 to 4 of 4
  1. #1
    Collinryans is offline Member
    Join Date
    May 2010
    Posts
    7
    Rep Power
    0

    Default Jar file could not find the main class

    I just clean and built main project in netbeans, however the jar file will not run. It gives me the error: could not find the main class: game.HangmanUI.
    I've already set that as my main class, the program works and everything just the jar file does not run.

    How do I get it to run?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,266
    Rep Power
    25

    Default

    Boy are there a lot of people having this problem.
    You need to do several things to provide info about your problem.
    Open a command prompt, change to the directory with the jar file and enter this:
    java -jar your-jarfilenamehere.jar

    Copy all of the screen and paste here.

    If your class is in a package, Open the jar file with some tool like WinZip and see that the path to the class file is the same as the package: game.HangmanUI

    Also open the manifest file that's in the jar file, copy it and paste its contents here.

  3. #3
    Collinryans is offline Member
    Join Date
    May 2010
    Posts
    7
    Rep Power
    0

    Default

    I just fixed it, turns out i had to put the datafile in the same directory as the jar :S i didnt realize thanks anyways, it helped actually cuz i needed to see the error from the cmd screen.

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

    Default

    Some instance quite similar thing happen if your application or the NetBeans project has more than on main class. In such cases you've define the what's the main executable for JAR package on project properties.

Similar Threads

  1. Could Not Find Main Class (again)
    By illjavathat in forum New To Java
    Replies: 25
    Last Post: 11-23-2010, 09:49 AM
  2. Could not find main class
    By Andyj in forum New To Java
    Replies: 2
    Last Post: 10-06-2009, 12:47 AM
  3. Replies: 1
    Last Post: 07-03-2009, 08:41 PM
  4. Could not find main class - JDK 1.6
    By Syranno in forum New To Java
    Replies: 1
    Last Post: 07-25-2008, 04:07 PM
  5. JVM Could not find main class
    By banduskank in forum Advanced Java
    Replies: 2
    Last Post: 06-24-2008, 08:05 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
  •