How to Run a Jar File



Introduction
Jar stands for Java Archive. These are specifically used by Java Compilers which contains a collection of classes, and other resources used by java program. These files can also be executed on user request.
There could be various ways of running jar files but in this article we will teach you to run jar file via command prompt.
Step 1 – Open the Command Prompt
Running jar files is very easy.
First of all, press the “windows + r” key to open the run window. Over there, type in cmd and hit the enter key in order to open the command prompt.
Opening the command prompt

Step 2 – Change directory
Once the command prompt opens, go to the directory where the jar file is saved. In our case, it was saved on the desktop. Thus, we will use the command “cd desktop”.
Use the change directory command

Step 3 – Enter the command
Once there, type the command “java –jar runable_jar.jar” and hit the enter key.
The “-jar” attribute is used to run the jar file using the java compiler. After the attribute comes the filename which is runable_jar and .jar is the file extension.
Once the command will be executed, the text present in the file will be displayed in the command prompt.
For the purpose of this tutorial, “Hello world” was the text present in the file that was part of the archive that we ran.
And this is how we can run jar file.
Command to run jar file