Jar file cannot find main class - gfSetup.jar (0/1)

Discussion in 'Java' started by James Alan Farrell, Jan 6, 2004.

  1. Hello all,
    Apologies if this is not the most appropriate group for this question.
    Please feel free to direct me to a better one.

    I have a small utility program that sets up a dialog which takes
    several pieces of data (file names) from the user and stores them into
    a file. All code resides in a single file. I attempt to create a jar
    file so that the user may run it conveniently from the windows
    desktop. When I attempt to run the jar file, I get an error: "Could
    not find main class. Program will exit!"

    I've looked at the jar file with winzip, and I've looked at the
    manifest. Everything looks right as far as I can tell. That is
    everything looks like it does for a very similar program that is
    working.

    Can anyone tell me what might be going wrong here. (Please don't say
    the problem is that I'm using Windows. My customer is adamant that we
    use Windows - it is what his customers - several hundred of them -
    use)

    I will attempt to include the jar file with this posting, so that you
    can see the files in it and the manifest. I'll also stash the source
    code into it, so that you may verify that main is declared correctly.

    The environment I am using is NetBeans 3.1, with the included jar
    packager. I've already checked the online documentation and other
    online sources. As far as I can see, syntax is correct.

    Thank you for your help,
    James Alan Farrell
    James Alan Farrell, Jan 6, 2004
    #1
    1. Advertising

  2. James Alan Farrell

    Tony Morris Guest

    Where is the jar ? and what is the syntax ?
    An "executable" jar file should contain a file called "META-INF/MANIFEST.MF"
    and that file should contain the entry: "Main-Class: com.blah.Main" which
    contains the main method.
    The class com.blah.Main should be packaged within that executable jar
    (since -jar ignores any classpath settings).

    --
    Tony Morris
    (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    Software Engineer
    IBM Australia - Tivoli Security Software

    "James Alan Farrell" <> wrote in message
    news:...
    > Hello all,
    > Apologies if this is not the most appropriate group for this question.
    > Please feel free to direct me to a better one.
    >
    > I have a small utility program that sets up a dialog which takes
    > several pieces of data (file names) from the user and stores them into
    > a file. All code resides in a single file. I attempt to create a jar
    > file so that the user may run it conveniently from the windows
    > desktop. When I attempt to run the jar file, I get an error: "Could
    > not find main class. Program will exit!"
    >
    > I've looked at the jar file with winzip, and I've looked at the
    > manifest. Everything looks right as far as I can tell. That is
    > everything looks like it does for a very similar program that is
    > working.
    >
    > Can anyone tell me what might be going wrong here. (Please don't say
    > the problem is that I'm using Windows. My customer is adamant that we
    > use Windows - it is what his customers - several hundred of them -
    > use)
    >
    > I will attempt to include the jar file with this posting, so that you
    > can see the files in it and the manifest. I'll also stash the source
    > code into it, so that you may verify that main is declared correctly.
    >
    > The environment I am using is NetBeans 3.1, with the included jar
    > packager. I've already checked the online documentation and other
    > online sources. As far as I can see, syntax is correct.
    >
    > Thank you for your help,
    > James Alan Farrell
    >
    Tony Morris, Jan 6, 2004
    #2
    1. Advertising

  3. "James Alan Farrell" <> wrote in message
    news:...
    ....
    | ...When I attempt to run the jar file, I get an error: "Could
    | not find main class. Program will exit!"

    It does sound like a manifest problem..

    | I've looked at the jar file with winzip, and I've looked at the
    | manifest. Everything looks right as far as I can tell. That
    is
    | everything looks like it does for a very similar program that
    is
    | working.

    With a 'blank line' at the end?

    | I will attempt to include the jar file with this posting,

    Fortunately these groups strip attachments,
    otherwise we'd have every noob (and their dog)
    zipping up their 100K of tortuous code and
    dumping it to the group..

    I suggest put it on the web, give us a link..

    --
    Andrew Thompson
    * http://www.PhySci.org/ PhySci software suite
    * http://www.1point1C.org/ 1.1C - Superluminal!
    * http://www.AThompson.info/andrew/ personal site
    Andrew Thompson, Jan 6, 2004
    #3
  4. James Alan Farrell

    nos Guest

    "Andrew Thompson" <> wrote in message
    news:rqvKb.79901$...
    > "James Alan Farrell" <> wrote in message
    > news:...
    > ...
    > | ...When I attempt to run the jar file, I get an error: "Could
    > | not find main class. Program will exit!"
    >
    > It does sound like a manifest problem..
    >
    > | I've looked at the jar file with winzip, and I've looked at the
    > | manifest. Everything looks right as far as I can tell. That
    > is
    > | everything looks like it does for a very similar program that
    > is
    > | working.
    >
    > With a 'blank line' at the end?
    >
    > | I will attempt to include the jar file with this posting,
    >
    > Fortunately these groups strip attachments,
    > otherwise we'd have every noob (and their dog)
    > zipping up their 100K of tortuous code and
    > dumping it to the group..
    >
    > I suggest put it on the web, give us a link..
    >
    > --
    > Andrew Thompson
    > * http://www.PhySci.org/ PhySci software suite
    > * http://www.1point1C.org/ 1.1C - Superluminal!
    > * http://www.AThompson.info/andrew/ personal site
    >

    Here is what mine looks like:
    ----
    Manifest-Version: 1.0
    Created-By: 1.4.1_02 (Sun Microsystems Inc.)
    Main-Class: NewDraw

    ----
    and NewDraw.java contains the 'main'
    nos, Jan 6, 2004
    #4
  5. "nos" <> wrote in message
    news:xwDKb.238179$8y1.1075498@attbi_s52...
    |
    | "Andrew Thompson" <> wrote in message
    | news:rqvKb.79901$...
    | > "James Alan Farrell" <> wrote in message
    | > news:...
    | > ...
    | > | ...When I attempt to run the jar file, I get an error:
    "Could
    | > | not find main class. Program will exit!"
    | >
    | > It does sound like a manifest problem..
    ....
    | > With a 'blank line' at the end?
    ....
    | > I suggest put it on the web, give us a link..

    | Here is what mine looks like:
    | ----
    | Manifest-Version: 1.0
    | Created-By: 1.4.1_02 (Sun Microsystems Inc.)
    | Main-Class: NewDraw
    |
    | ----

    I assume that means the blank line _is_ there

    | and NewDraw.java contains the 'main'

    What do you mean when you say NewDraw.java
    _contains_ the main, NewDraw.java is source
    and does not need to be in the jar. Did you mean
    that NewDraw.class is in the root of the jar file?

    How big is the jar, and can you put it on the Net?

    --
    Andrew Thompson
    * http://www.PhySci.org/ PhySci software suite
    * http://www.1point1C.org/ 1.1C - Superluminal!
    * http://www.AThompson.info/andrew/ personal site
    Andrew Thompson, Jan 7, 2004
    #5
  6. Hello again,
    Sorry, did not realize the news group would not allow attachments.
    I'll talk to my dog about that (Bad dog!)

    Anyway, there were two carriage return/line feed pairs at the end of
    the manifest. I tried it with only 1 ANDwithout any, without success.
    Exactly what do you mean by a blank line, and how many should there
    be?

    Here is what the manifest looks like:

    Manifest-Version: 1.0
    Main-Class: gfSetup.gfSetupProg
    Created-By: Netbeans IDE

    Since I cannot attach, you'll have to take my word that the package
    and class names are correct. The class gfSetupProg contains a
    function declared as:

    public static void main (String[] arguments)
    {
    gfSetupProg genFormatter = new gfSetupProg();
    } // end main

    and the class itself is declared as public:

    public class gfSetupProg
    extends JFrame
    implements ActionListener
    {
    ....

    I've tried several different things with the manifest, such as placing
    the Main-Class line at the end (before the blank line(s)), and using a
    forward slash instead of a dot. As I said in my first message, I have
    one that works that looks like this (2 blank lines, the Main-Class on
    the second line, a dot instead of a slash).

    Any other advice would be appreciated!

    Thanx,
    James
    James Alan Farrell, Jan 9, 2004
    #6
  7. "James Alan Farrell" <> wrote in message
    news:...
    ....
    | Sorry, did not realize the news group would not allow
    attachments.
    | I'll talk to my dog about that (Bad dog!)

    I hope the dog bites you, for blaming them,
    dogs get blamed for enough already!

    | Exactly what do you mean by a blank line,

    a ..line with no characters, no letters, no numbers..

    | and how many should there
    | be?

    1

    | Here is what the manifest looks like:
    |
    | Manifest-Version: 1.0
    | Main-Class: gfSetup.gfSetupProg
    | Created-By: Netbeans IDE
    | *

    * is that a blank line, or just a space before you
    resume the post??

    | Since I cannot attach, you'll have to take my word that the
    package
    | and class names are correct.

    I trust no-one. You can put it on the net
    and give a URL..

    --
    Andrew Thompson
    * http://www.PhySci.org/ PhySci software suite
    * http://www.1point1C.org/ 1.1C - Superluminal!
    * http://www.AThompson.info/andrew/ personal site
    Andrew Thompson, Jan 9, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hiwa
    Replies:
    1
    Views:
    1,571
    James Alan Farrell
    Jan 13, 2004
  2. cyril
    Replies:
    2
    Views:
    3,857
    cyril
    Aug 25, 2004
  3. Ike

    Cannot find main class

    Ike, Jan 30, 2007, in forum: Java
    Replies:
    3
    Views:
    4,023
    Knute Johnson
    Jan 31, 2007
  4. Replies:
    2
    Views:
    802
  5. Grzesiek
    Replies:
    5
    Views:
    12,874
Loading...

Share This Page