Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Thanked 0 Times in 0 Posts

    Executable jar file,Main-class manifest,Error: Can't Find Main class

    I have a file called piggybankrun. It contains five(5) source files(including one called PiggyBankMain.class, which has only the class title and public static void main(String[])), and a manifest file. The manifest file has a single line of code: "Main-Class: PiggyBankMain" I typed a carriage return after. I am using the cmd.exe to put the jar file together. After getting to the 'bin' folder I type:

    ...>jar cfm f:\piggybank.jar f:\piggybankrun\manifest.mft f:\piggybankrun\*

    It creates a .jar file successfully. I double click on the .jar file and it says: "Could not find the main class. Program will exit."

    If you could, please explain where I may have screwd up. If I left out some information you need please ask. Thanks.

    PS: If it matters I'm using a JFrame that pops up. Thanks again.

  2. #2
    Regular Coder
    Join Date
    Oct 2006
    United Kingdom
    Thanked 30 Times in 29 Posts
    Have you tried to view the contents of the Jar File? Usually, I inspect the contents using WinRar...by just opening the contents of the jar file.

    Try doing it the following way.
    Step 1
    Compile by executing javac *.java

    Step 2
    execute the following command

    jar cvf MyApp.jar *.class

    Step 3
    Create a text file and call it Main.txt...then write the following inside it
    Main-Class: MyApp

    Don't forget to add an empty line after the "Main-Class: MyApp"

    Once you have done that, execute the following command to update the JAR file with the mainifest

    jar umf Main.txt MyApp.jar

    That should do the trick

    If that doesn't work...try the following command

    java -jar MyApp.jar

    in case your path is not configured correctly.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts