Jelle Klap wrote:Have you added the appropriate Main-Class entry to the JAR file's META-INF/MANIFEST.MF (tutorial)?
Nicu Surdu wrote:
this is my script, I'm following some tutorials, I've compiled and in the command line is ok, the message is shown, but when I double clikv on jar nothing is happenig...
Henry Wong wrote:
Nicu Surdu wrote:
this is my script, I'm following some tutorials, I've compiled and in the command line is ok, the message is shown, but when I double clikv on jar nothing is happenig...
This is a repeat of your question (with some code). Please answer Jelle's question.
Henry
Jesper de Jong wrote:When you double-click on an executable jar file, then you won't have the console window (or it appears and disappears immediately), so you won't see output that you print with System.out.println().
Your program only does one thing: print "My First Project" on the console, and then you have a few other statements in the main method but they don't have any effect. Since there is no console when you double-click the jar, you won't see anything.
Nicu Surdu wrote:
Jesper de Jong wrote:When you double-click on an executable jar file, then you won't have the console window (or it appears and disappears immediately), so you won't see output that you print with System.out.println().
Your program only does one thing: print "My First Project" on the console, and then you have a few other statements in the main method but they don't have any effect. Since there is no console when you double-click the jar, you won't see anything.
Yes when I double click nothing is happening, this is correct? (I want to see the message shown somewhere)....
Nicu Surdu wrote:
I mean should print the message but I can see anything printed .....( where to see the message??? the console isn't opeded).. I mean I executed the jar file from inside the cmd.exe and there in console the message is printed ....
Jesper de Jong wrote:Nicu, I tried to explain it to you:
When you double-click an executable jar file, there is no console window, so you will not be able to see the output.
When you run it from the command prompt yourself (cmd.exe) with a command like "java -jar myfile.jar" then the console is available and you will see the message. But not when you do not have a command prompt window open and you double-click the icon of the jar file.
That's just how it works. You're not going to be able to see console output when you double-click the jar to run it.
So, if you want to be able to run your program by double-clicking the jar, then you'll have to do something else instead of using System.out.println(). For example, show a message dialog. I see you already imported javax.swing.JOptionPane in your program, but you're not using it anywhere. Example:
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |