I am quite new to Java and I am working on a personal project to learn the language. I use Eclipse (Kepler) as IDE.
Most things work well at the moment and I wanted to try to export my project so I can run it outside of Eclipse.
I used Eclipse's "Export" function to create a "runnable JAR". Here is my first question: Should I be able to run this file directly? Because when I double click it in the windows explorer, nothing happens.
I also tried to make an .exe out of that .jar by using "Launch4j". This worked without error messages, but the same as above: When I double click the .exe in the windows explorer, nothing happens.
At this stage, I thought I maybe made a programming error, so I created a test file which contains only the following code:
The result was the same as before: The .jar and the .exe are created without problems, but they simply do nothing...
Can anybody help me?
(Sorry if my English is not always the best, I am from Germany.)
By using "java -jar MyFile.jar" in the command line, it is possible to run the test project as well as the real project, so my project seems to work like it should.
For the future, I want to give the program to some friends for alpha/beta testing and I would prefer to be able to start it the "usual" way for an end user, by double clicking it in the explorer. Is that also possible? The program has a basic GUI, but for error messages I currently use the usual System.err.println(), which requires the command line, right? In the final version, the command line should not be required anymore.
if you want to allow end users to run the program by double clicking then you may want to look into JNLP.
Well, if double clicking a jar file that runs fine via "java -jar MyFile.jar" does not run it, then anything more complicated like JNLP probably would not work either. That's just speculation, but apparently something went wrong during installing Java, because that generally registers jar files as double-clickable automatically. So I would advise to stay away from JNLP and .exe files for the moment. One thing to try would be to take the jar file to another computer and test its double-clickability there; maybe there's something wrong specifically about the Java installation on your machine.
I tried some additional things now: I brought the .jar to two different computers and I reinstalled the JRE on my laptop. The result is the same as before: I can start the program by using the command line but not by double clicking.
I also checked what the default program for opening a .jar is. I did a right click on the .jar, and choose "open with". The default (and the single available) program is "Java(TM) Platform SE binary", is this correct?
I also read this, but I did not find my problem. I also checked the manifest files. They seem to be correct, too.
Here is the manifest file of the test project: