Create and Extract JAR | Core Java Tutorials
This Core Java Tutorials “Create and Extract JAR” post is providing complete information about what is jar file in java, how to create JAR file and how to extract JAR file in Java.
- JAR stands for java archive file.
- Java Library is a collection of JAR files.
- JAR is the collection of packages.
- Package is the collection of classes and interfaces.
- Every java application is the combination of JAR files.
- We need to set “class path” to work with JARs.
- “path” is to provide information about executable files to Operating System.”path” is to provide information about executable files to Operating System.
path = “value-location of executable files”
- “class path” is to provide the information about JAR files which are used in java application.”class path” is to provide the information about JAR files which are used in java application.
classpath = “value – location of jar files”
Syntax to create jar file :
- cmd> jar cf <jar file name> <package1> <package2> …..
With the help of all the specified packages jar file will be created.
Syntax to extract jar file :
- cmd> jar xf <jar file name>
Extracts all the packages from the specified jar file in the current working directory.
- All the class files which are used to develop basic java applications (core applications) belong to “rt.jar” file.
- No need to set the class path to work with rt.jar file in java application.
- Following commands are used to extract and create JAR files.