简体   繁体   中英

Exporting an Eclipse Project into a Runnable Jar does not work

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.

Make sure the jar contains manifest file with correctly specified main class. Follow these instructions: http://www.skylit.com/javamethods/faqs/createjar.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM