Results 1 to 4 of 4
  1. #1
    Himanshu23 is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default jar file ERROR:Could not find the main class. program will exit.

    // hi.java
    import javax.swing.JOptionPane;
    class hi{
    public static void main(String args[]){
    JOptionPane.showMessageDialog(null,"hi");
    }
    }

    /*
    step 1: javac hi.java
    step 2: jar -cf hi.jar hi.class
    step 3:append "Main-Class: hi" in "META.MF/manifest.mf"
    ERROR: Could not find the main class. program will exit.
    */
    Last edited by Himanshu23; 11-11-2010 at 08:01 AM. Reason: more details

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    Make sure you end that line in manifest.mf with a new line as described in the Setting an Application's Entry Point page of Oracle's Tutorial.

  3. #3
    Himanshu23 is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default

    i have given a space after the line of Main-Class and it is followed by an enter key
    yet it is giving an error

  4. #4
    Himanshu23 is offline Member
    Join Date
    Nov 2010
    Posts
    9
    Rep Power
    0

    Default

    Quote Originally Posted by Himanshu23 View Post
    i have given a space after the line of Main-Class and it is followed by an enter key
    yet it is giving an error
    My manifest file looks as shown below, yet "Could not find the main class. program will exit." error message is coming

    "Manifest-Version: 1.0
    Created-By: 1.7.0-ea (Sun Microsystems Inc.)
    Main-Class: hi
    "

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2011, 10:48 PM
  2. Could not find the main class, program will exit
    By grottesco in forum New To Java
    Replies: 7
    Last Post: 11-03-2010, 07:51 AM
  3. Could not find the main class. Program will exit.
    By XSROSSITER in forum New To Java
    Replies: 0
    Last Post: 01-30-2010, 05:17 AM
  4. Replies: 1
    Last Post: 07-03-2009, 09:41 PM
  5. Could not find the main class. Program will exit.
    By Carrier in forum New To Java
    Replies: 1
    Last Post: 04-22-2009, 03:27 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
  •