foobarrington
foobarrington

Reputation: 27

Multiple ways of creating executable jar not working

I'm trying to make a jar that the user can double-click to run (not a .exe just a jar that can be double-clicked). The problem is while this question has been asked many times none of the answers have worked.

I think the problem is not on my system, because other jar files on my system (that I didn't create) run fine. This makes me suspect I am doing something wrong.

First I tried this example.

However when I tried running the jar I made with that solution with:

java -jar HelloWorld.jar

I got the error: "no main manifest attribute in HelloWorld.jar"

I suspect the error is with my manifest file so here is is:

Manifest-Version: 1.0
Main-Class: main.Main

I also tried: "File --> Export --> RunnableJar" in eclipse but while that allowed me run to my jar from the command line when I tried double-clicking it I got the following message: "A Java Exception has occurred".

At this point, I don't know what to do to make my jar double-clickable.

What can I do to make my jar double-clickable?

Update: I used a new command:

jar cfe HelloWorld.jar main main.class

Now when I try to run this new jar from the command line with

java -jar HelloWorld.jar

I get the following error: "Could not find or load main class main"

Upvotes: 1

Views: 76

Answers (1)

user1134181
user1134181

Reputation:

If you did everything as described in that example, I think that there is no association with the *.jar file in the registry. Check it.


Also it maybe that two versions of Java installed. Check Right-Click -> Open With. Java Runtime should be listed there.

Upvotes: 2

Related Questions