Reputation: 1452
I'm trying to export my java application to a Runnable Jar file. This worked before, but apparently I've tinkered with something and now it doesn't work.
Exporting from Eclipse works without problems, but when I'm starting the .jar an error shows up:
"Could not find the main class: game.Main. Program will exit."
Now, the game.Main class is my main class so that's ok. When I run the .jar via command line like this:
java -cp D:\PathToMyJar\test.jar game.Main
It also works just fine. I just can't run the .jar file itself.
The Run Configuration with which I'm exporting is set to the correct Project and main class. I hardly used Eclipse's export features before, so I'm kinda out of options I could think of. From what I've read it might be some problem with the manifest file, but I don't know where to check it or how to change it - apart from the fact that Eclipse should be able to do that on it's own somehow ...
PS: The manifest inside the jar file looks like this:
Manifest-Version: 1.0
Class-Path: .
Main-Class: game.Main
Main-Class is correct. I don't know what Class-Path generally is, but I guess that means wildcard, so OK too.
Upvotes: 1
Views: 9322
Reputation: 2812
Make sure the jar contains manifest file with correctly specified main class. Follow these instructions: http://www.skylit.com/javamethods/faqs/createjar.html
Upvotes: 2