- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Jar files in Java
85 Lectures 6 hours
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
- How can we create a multi-release jar(mrjar) using jar tool in Java 9?
- What is a Multi-Release jar(mrjar) in Java 9?
- Temporary files in Java
- Multiple .java files
- What is a JAR file?
- How to run a JAR file through command prompt in java?
- How to make seleinum jar file , and how to test using Selenium jar file?
- How to create a JAR file?
- What is the use of a multi-version compatible jar in Java 9?
- Working with csv files in Java
- Rename multiple files using Java
- Java program to delete all the files in a directory recursively (only files)
- How to add jar as library on Android Studio?
- How to move files using FileUtils in Java?
- Error connecting SAP while sapjco3.jar file is in my library path