1

I am having lots of trouble with Creating a .jar file. every time i try to create one it, an error window pops up and says that the main class Start can not be found. (My main class is named Start) I have a manifest and everything can you tell me what i'm doing wrong please, or tell me what do do exactly? This can be from the command prompt or from eclipse as well!

Also sometimes a command prompt window pops up for a millisecond then closes in an instant!

My manifest says:

Manifest-Version: 1.0
Main-Class: Start

My main class is Start.class

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
mrspy1100
  • 41
  • 1
  • 1
  • 4
  • 2
    What's in your manifest, what's in your jar file (jar tvf), and what's the full name of the class with main() in it? – user207421 May 20 '12 at 04:25
  • 2
    Are you taking into account your packages? – Hovercraft Full Of Eels May 20 '12 at 04:25
  • 1
    *"I have a manifest and everything"* Better than vague claims is a copy/pasted listing of the content (done by the Jar command). – Andrew Thompson May 20 '12 at 04:25
  • Please refer this http://stackoverflow.com/questions/3570845/java-eclipse-executable-jar-file – Umesh Aawte May 20 '12 at 04:25
  • 1
    *"sometimes a command prompt window pops up for a millisecond then closes in an instant!"* Run the Jar from the command line using something like `>java -jar the.jar`. It will still crash, but should dump the output to the console. Copy/paste the output as an edit (along with the Jar structure). – Andrew Thompson May 20 '12 at 04:28
  • 1
    Will you please stop editing the question so fast that you wipe out my edits? I already fixed the manifest listing once! – Andrew Thompson May 20 '12 at 04:30

1 Answers1

2

Here's my vague answer to your vague problem. It can be a variety of things. But the most probable one is than you have declared the Start class inside a package and didn't put the fully qualified class name in the manifest.

Assuming the package you have declared Start class in is foo.bar.lazy you need to give Main-Class: foo.bar.lazy.Start.

Thihara
  • 7,031
  • 2
  • 29
  • 56
  • Where does the declaration start at? Do i do it like this? src.robert.Start? – mrspy1100 May 20 '12 at 04:57
  • On the top of your Start source file they'll be something like package foo.bar.lazy; you need to put whats there. Read this http://en.wikipedia.org/wiki/Java_package for more information on packages. – Thihara May 20 '12 at 05:08
  • I don't see anything called foo.bar.lazy! Is this supposed to be there in the manifest? – mrspy1100 May 20 '12 at 05:26
  • 3
    I'm not sure if you are joking, but... he didn't mean you should actually see foo.bar.lazy (heh) - you should see the fully qualified name of your main class. Foo and bar are often used by programmers as class names to make points. – Kelly May 20 '12 at 06:18