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

  • Thread starter James Alan Farrell
  • Start date
J

James Alan Farrell

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
 
T

Tony Morris

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).
 
A

Andrew Thompson

....
| ...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..
 
N

nos

Andrew Thompson said:
...
| ...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:
 
A

Andrew Thompson

|
| | > | > ...
| > | ...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?
 
J

James Alan Farrell

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
 
A

Andrew Thompson

....
| 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..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top