0

I've been programming in java for a few months now and I decided to make an Atari breakout style game. I am now finished with the game and want to make it a runnable jar file in Eclipse so I went to File -> Export -> Runnable JAR File. Under Launch configuration I put "Outbreak - Out Break" because the class with the main method is Outbreak in the file Out Break. I then exported it to my desktop and set the library handling to "Extract required libraries into generated Jar". and I did not save it as an ANT script. After the runnable Jar is created, I go on my desktop and try to run it but I get the error Could not find the main class: Outbreak. Program will exit. This makes no sense to me especially because it runs fine in Eclipse. Please help me if you can!!!

Matt32
  • 26
  • 4

2 Answers2

0

You need to check the META-INF/MANIFEST.MF file inside your exported jar. The class you want to be executed should be there and should be included in the classpath as well.

Garry
  • 4,493
  • 3
  • 28
  • 48
0

Guessing on the obvious:

the main method is Outbreak in the file Out Break

  • The class file name should have the same name as the contained class (omitting the .java part)
  • The main method should be public static void main(String[] args)

This might sound ridiculous, but if you run it as something else than a Java Application from eclipse, eclipse might happily execute it. A Java Application will not run from eclipse without the main method. How do you execute the application in eclipse? (Run as > Java Application ?)

If this is not your problem, you might want to rephrase your question and include sample code. META-INF/MANIFEST.MF, the file that Garry mentions in the other answer, should be automatically generated by the export process - check the resulting jar by unzipping it. You can also include it in your own project and maintain it yourself instead of relying on the automatic process.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90