
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
Jar files in Java
JAR is a file format that helps in aggregating Java class file, along with its associated metadata and resources into a single file.
Creation of a JAR file − The jar cf command can be used, where ‘cf’ means creating the file.
jar cf jar_file_name files_to_compress
Once a jar file has been created, a default manifest file is also created. Only one manifest file is present in a specific archive, and it will have the extension ‘mf’ and will be in the pathname. This
manifest file helps give information about the files that have been compressed/present in the package.
Viewing a JAR file − The ‘jar tf’ command can be used to view the file that has been compressed. Here, ‘tf’ represents viewing the table contents.
jar tf jar_file_name
Extracting contents from a jar file − The ‘xf’ command can be used to extract the contents from a jar file. Here, ‘xf’ represents extraction.
jar xf jar_file_name
Updating the jar file − The ‘uf’ command is used to update, where ‘u’ represents updating of contents of an existing jar file. This is done by modifying the manifest file or by adding new files.
jar uf jar_file_name other_input_files
Running a jar file −If an application is compressed as a jar file, the below command can be used.
FILE_LOCATION:\>java –jar file_name.jar
- Related Articles
- Runtime JAR File in Java
- How can we create a multi-release jar(mrjar) using jar tool in Java 9?
- Temporary files in Java
- Multiple .java files
- How to run a JAR file through command prompt in java?
- What is a Multi-Release jar(mrjar) in Java 9? \n
- Working with csv files in Java
- What is the use of a multi-version compatible jar in Java 9?
- Java program to delete all the files in a directory recursively (only files)
- Rename multiple files using Java
- How to move files using FileUtils in Java?
- Compare Two Different Files Line by Line in Java
- How to make seleinum jar file , and how to test using Selenium jar file?
- What is a JAR file?
- How to list all files in a directory using Java?
