1

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"

Community
  • 1
  • 1
  • 2
    Fix error caused by the exception. – Roman C Sep 27 '15 at 14:19
  • 1
    Run it with java -jar HelloWorld.jar to know what the exception is, then fix it. If you have done that and it works, then it means the java version used when double-clicking is not the same as the one used from your command prompt. – JB Nizet Sep 27 '15 at 14:19
  • Try this command - (Assuming your manifest file is named mani) jar cfm HelloWorld.jar mani.mf *.class – Sanved Sep 27 '15 at 14:23
  • @JBNizet The thing is, the jar file I made with eclipse works fine from the command line there is no exception. The exception only happens when I double-click the jar. – foobarrington Sep 27 '15 at 14:30

1 Answers1

2

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.