---
title: "Executing a Java program using JAR file"  
description: "How to create a JAR file in Command Prompt:Start Command Prompt. Navigate to the folder that holds your class files;C:\\cd mywork  Set path to include"  
author: "Devesh Kumar Singh"  
published: 2015-10-30  
updated: 2018-03-13  
canonical: https://www.mindstick.com/blog/10974/executing-a-java-program-using-jar-file  
category: "java"  
tags: ["java", "javac", "command line", "jar"]  
reading_time: 1 minute  

---

# Executing a Java program using JAR file

How to create a [JAR](https://www.mindstick.com/forum/159220/how-can-i-create-an-executable-runnable-jar-with-dependencies-using-maven) [file](https://www.mindstick.com/articles/59/encrypting-and-decrypting-files-using-c-sharp) in [Command Prompt](https://answers.mindstick.com/qa/51716/how-to-make-bootable-pendrive-using-cmd-windows-command-prompt):

· Start Command Prompt.

Navigate to the folder that holds your [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud);

C:\cd mywork

\
![Executing a Java program using JAR file](https://www.mindstick.com/blogs/82ae31b8-f74c-4443-a475-8143ff87d8c3/images/2a14d34a-0dea-4a6e-8daa-e77a75722ef8.png)

· Set path to include JDK’s bin. For example;\
C:\mywork> set path=c:\Program Files (x86)\Java\ldk1.8.0_31\bin

![Executing a Java program using JAR file](https://www.mindstick.com/blogs/82ae31b8-f74c-4443-a475-8143ff87d8c3/images/1064718c-417d-4d15-a147-375103833fb4.png)

· [Compile](https://www.mindstick.com/forum/2316/how-to-views-compile-in-mvc) your class(es);

C:\mywork> javac HelloWorld.[java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)

\
![Executing a Java program using JAR file](https://www.mindstick.com/blogs/82ae31b8-f74c-4443-a475-8143ff87d8c3/images/ca95b8ad-ad83-40db-a352-a4ef50a41d7e.png)

· Create a Manifest file and your Jar file;\
C:\mywork> echo main-Class: Hello >manfest.txt\
C:\mywork> jar cvfm Hello.jar manifest.txt HelloWorld.class\
or \
C:\mywork> jar cvfe Hello.jar Hello HelloWorld.class

This will create your manifest and jar file in the location where your java program is.

· Test your jar directly by typing the following command on your command prompt or simply double click the Hello.jar file from where it is saved.

C:\mywork> Hello.jar

or

C:\mywork> java –jar Hello.jar

This will run your java program using JAR file.

---

Original Source: https://www.mindstick.com/blog/10974/executing-a-java-program-using-jar-file

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
