Suppose I made a program to take two input and display the sum. It runs in netbeans but when I build out the jar file , and double clicked the jar file , nothing happens. How can I make these program run?
Asked
Active
Viewed 53 times
1
-
Turn it into an executable jar Link: http://stackoverflow.com/questions/5258159/how-to-make-an-executable-jar-file – Shloim Nov 22 '15 at 11:46
-
@Shloim that question is about swing, this here is about a consoleapp – Nov 22 '15 at 11:48
-
I know, but it's the exact same set of instructions. – Shloim Nov 22 '15 at 11:50
3 Answers
0
You must run this from command line, and then execute java -jar {PATH_TO_JAR}

Albert Bos
- 2,012
- 1
- 15
- 26
0
You can use the command-line :
java -jar <yourjar> <yourMainClass>
You can also add the main class in a manifest file into the jar. Doing so, you don't need to specify anymore on command line

Prim
- 2,880
- 2
- 15
- 29
0
Jar files needs to run in JVM - Java Virtual machine, to run your file use: "java -jar" and your jar. By doing so, you tell Java to run your jar in jvm which means it now can run.

user2517841
- 1
- 2