Executable JAR files are the simplest way to assemble Java code into a single file that can be executed. *(Editorial Note: Creation of JAR files should be covered by a separate Topic.) *
Assuming that you have an executable JAR file with pathname <jar-path>
, you should be able to run it as follows:
java -jar <jar-path>
If the command requires command-line arguments, add them after the <jar-path>
. For example:
java -jar <jar-path> arg1 arg2 arg3
If you need to provide additional JVM options on the java
command line, they need to go before the -jar
option. Note that a -cp
/ -classpath
option will be ignored if you use -jar
. The application's classpath is determined by the JAR file manifest.