I’ve made a command line application in Java using Eclipse. I’ve created a runnable JAR and understand that if I want to run it, I need to do it via command prompt. Is there any way to have the .jar open a command prompt and run the program on click?
Edit: To clarify, the program works in Eclipse’s console, and running the .jar I created through the command prompt works (i.e. java -jar Minesweeper.jar). I’d just like it to execute like that when I click on the .jar file.
I’ve noticed this problem when trying to run a command line base app as a runnable jar file. It works fine if you try to do something like creating and showing a jframe. My only suggestion is if you are on windows you can make a batch file that has the line:
Name the file something like run.bat and then you can double click on that and it will run the command line app. Other than that im not sure why this problem occurs with command line input based applications.
EDIT:
Here is a way to make a fake command prompt to display to if you cant figure out a way to get the real one to run from double clicking the jar.
Also, can you tell me the steps you are using to create the runnable jar file. The code above should run by double clicking on the jar file. If it doesn’t, then something might be wrong with the way you are creating the jar file.