Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
How to Install Eclipse IDE For Java?
Next article icon

How to Create Jar File for Java Project in Eclipse?

Last Updated : 23 Nov, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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"  pause
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. 


Next Article
How to Install Eclipse IDE For Java?

N

nandinigujral
Improve
Article Tags :
  • Java
  • Technical Scripter
  • How To
  • Technical Scripter 2022
Practice Tags :
  • Java

Similar Reads

  • How to Debug a Java Project in Eclipse?
    Every Java developer needs to work in Debug mode to resolve the errors. Experienced Java developer already knows how to debug the code but if you are new as a Java developer this article will cover the topics which help to debug the code faster in eclipse and also use the "Debug Mode" efficiently an
    3 min read
  • How to Create a Maven Project in Eclipse IDE?
    Maven is a powerful project management tool that is based on POM (project object model). It is used for project build, dependency, and documentation. It simplifies the build process like ANT. But it is too much advanced than ANT. In short terms we can tell maven is a tool that can be used for buildi
    2 min read
  • How to Create a .exe File From a Java Program?
    In this article, we will learn how to create a .exe file from a Java program. Java is a platform-independent language, which works on the philosophy of "write Once, Run Anywhere". It simply means that if we write a Java program, we can run it on any device that has a JVM(Java Virtual Machine). Now i
    5 min read
  • How to Add JAR file to Classpath in Java?
    JAR is an abbreviation of JAVA Archive. It is used for aggregating multiple files into a single one, and it is present in a ZIP format. It can also be used as an archiving tool but the main intention to use this file for development is that the Java applets and their components(.class files) can be
    4 min read
  • How to Install Eclipse IDE For Java?
    There are many software been there such as IntelliJ IDEA, Eclipse, etc of which most developers are tilted towards using Eclipse is open-source software. It is mainly used for JAVA applications development. We can also use it to develop applications in various programming languages like C, C++, C#,
    2 min read
  • How to Install Eclipse for C++ in MacOS?
    C++ is basically a programming language. It is an Object-Oriented Programming Language. That means here we can use classes, objects, and other useful items. For developing purposes C++ is widely used. For this reason, we need to have an IDE. Eclipse is an IDE. It is used for many programming languag
    2 min read
  • How to Create a Project In NetBeans GUI?
    All Java Development in the IDE takes place within Projects, we first need to create a new project within which to store sources and other project files. An IDE project is a group of JAVA Source files plus its associated metadata (data about data), including project-specific properties files, and ma
    2 min read
  • How to Install Eclipse for C++ on Linux?
    Eclipse is an IDE (integrated development environment) used for building software. It was initially released by IBM on 7 November 2001. Using eclipse, we can develop applications with Java, PHP, and C/C++ programming languages. It's one of the most popular open-source IDE among developers. In today'
    2 min read
  • How to Execute a .class File in Java?
    A Java Class file is a compiled java file. It is compiled by the Java compiler into bytecode to be executed by the Java Virtual Machine. Step #1: Compile the .java File Open Terminal (Mac) or Command Prompt (Windows). Navigate to the folder containing the java file and type the following command to
    1 min read
  • How to Create Different Packages For Different Classes in Java?
    Let us first know what is a class and package in Java. Class in java is a model for creating objects. It means that the properties and actions of the objects are written in class. Properties are represented by variables and actions of the objects are represented by methods. So, a class contains vari
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences