Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Jar file cannot find main class - gfSetup.jar (0/1)

Reply
Thread Tools

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

 
 
James Alan Farrell
Guest
Posts: n/a
 
      01-06-2004
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

 
Reply With Quote
 
 
 
 
Tony Morris
Guest
Posts: n/a
 
      01-06-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      01-06-2004
"James Alan Farrell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
....
| ...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


 
Reply With Quote
 
nos
Guest
Posts: n/a
 
      01-06-2004

"Andrew Thompson" <(E-Mail Removed)> wrote in message
news:rqvKb.79901$(E-Mail Removed)...
> "James Alan Farrell" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> ...
> | ...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'



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-07-2004
"nos" <(E-Mail Removed)> wrote in message
newswDKb.238179$8y1.1075498@attbi_s52...
|
| "Andrew Thompson" <(E-Mail Removed)> wrote in message
| news:rqvKb.79901$(E-Mail Removed)...
| > "James Alan Farrell" <(E-Mail Removed)> wrote in message
| > news:(E-Mail Removed)...
| > ...
| > | ...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


 
Reply With Quote
 
James Alan Farrell
Guest
Posts: n/a
 
      01-09-2004
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
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-09-2004
"James Alan Farrell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
....
| 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not find Main Class while executing JAR Grzesiek Java 5 09-10-2007 12:12 AM
JAR[error] : could not find main class asiankent@gmail.com Java 2 03-13-2007 09:23 AM
instanciate a class in a jar file with class.forname, while my main class is in another jar cyril Java 2 08-25-2004 06:55 AM
Jar file cannot find main class - gfSetup.jar (0/1) hiwa Java 1 01-13-2004 01:41 AM



Advertisments