Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Create Jar File for Java Project in Eclipse?

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 23 Nov, 2022
Improve Article
Save Article

Java programmers already know about what is a jar file if you are new then first understand what is a jar file. Once you are completed your project in Eclipse the next task is to create a runnable version of your project. Eclipse support only exporting the JAR (.jar) file, not the Executable (.exe) file. It is very important to learn as a Java programmer as it is the most used tool. This article will teach you how to create a JAR file and then an Executable file with a JAR file. 

Steps to Create a JAR file in Eclipse

A JAR (Java Archive) file is a ZIP format file that bundles Java classes into a single unit, it contains all the resources needed by Java applications as well. There are two types of the JAR file in Java 

  • Library JAR files – reusable libraries like Maven Jar file.
  • Executable JAR files – executed as standalone Java applications. 
project structure

project structure

Step by Step Implementation

Step 1: Refresh your project – First right click on your project and click on Refresh. This step ensures your code is up to date.


Step 2: Right-click your project and click on Export. An Export window box will appear on the screen. 


Step 3: Expand the “Java” folder and select the “Runnable JAR file” then click on the Next button.


Step 4: A new window box will appear on the screen. First, have to select the main class of a project that indicates where your program begins and contains the main method.  Click on the drop-down menu under  “Launch configuration” to select the main file. 

Step 5: After that select the destination of the runnable JAR file. Click on Browse. Select the folder you want to save the JAR file to. Type a name for the JAR file next to “Filename”. then click on the Save button. Path for Runnable JAR file 

F:\JAR file\calculator 
driver - F:\      folder name - JAR file\      file name - calculator 

Step 6: Make sure the “Extract required libraries into generated JAR” radio button is selected. Do not worry about the rest of the menu. Click on Finish Button. Your Java project is exported as a JAR file.


Note: If you have warnings in your project then you will get one dialog box at the end, Click on the Ok button simply. 

Steps to Create a Batch file in Eclipse

Creating a batch file to automate repetitive tasks is easy, once you know how. The batch script is a simple text file that is used to run different commands in sequence. It can automate and convert a Java Project into something anyone could operate.

Step by Step Implementation

Step 1: Create a text file, such as a Notepad or WordPad document where you have created the JAR file.


Step 2: Add command

java -jar "C:\Users\New folder\JAR File\calculator.jar"
java -jar "path of JAR file"


Step 3: Save your file with the file extension BAT, for example, run.bat.

Step 4: To run your batch file, double-click the BAT file you just created. 

Note: To edit your batch file, right-click the BAT file and select Edit. 

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!