Java Language The Java Command - 'java' and 'javaw' Running an executable JAR file

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.



Got any Java Language Question?