I am writing a java applicaiton that outputs strings via System.out and I just want to know how to run this application outside my IDE. I have an executable jar. What does one do to see this output in a console?
To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]
jar file from the Linux terminal. To do this, you must have java command line tool installed to launche a Java application, and the -jar flag to execute a program encapsulated in a JAR file. When this flag is used, the specified JAR file is the source of all user classes, and other class path settings are ignored.
Basically: java -jar app.jar
Sun's site has more info
As others have suggested:
java -jar JarFIle.jar
Note this requires you to set the main class entry point
If you don't/can't set Main-Class then you would do:
java -cp JarFile.jar package.Classname
Additionally if you associate jar file types with your JRE then double click should work too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With