Java: Working with Jar File

By Xah Lee. Date: . Last updated: .

A jar file (aka Java Archive) is a zip compressed bundle of compiled java class files.

Use jar tool to create or unpack jar files.

View Jar File

# list contents of the file x.jar
jar tf x.jar

How to View Content of Manifest File?

# list MANIFEST content of a jar file
unzip -p myfile.jar META-INF/MANIFEST.MF

The file “META-INF/MANIFEST.MF” is basically a index of the archive.

Example of a jar manifest file content:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: hudson
Build-Jdk: 1.6.0_20
Main-Class: clojure.main

Creating Jar File

Here's a example of creating a jar file:

# create a java jar file
# name it aa.jar
# specify the program entrypoint is class Bb
# contains all files of the pattern *.class and cc*/*.class
jar cvfe aa.jar Bb *.class cc*/*.class

Extract Jar File

# extract jar file
jar xvf x.jar


  1. Install
  2. javac java jar javadoc

Java Basics

  1. Print String
  2. Strings
  3. Power Function
  4. Java Types and Type Conversion
  5. Function
  6. Arrays

Class, Inheritance

  1. extends
  2. Constructor
  3. Constructor Return Type
  4. Extending a Class that has Explicit Constructors
  5. static
  6. this
  7. super
  8. Access Specifiers

Abstract class, Interface

  1. abstract
  2. Interface


  1. Package


  1. Collection, Map
  2. Read/Write File
  3. Convert File Encoding
  4. Complex Numbers in Java
  5. Unicode
  6. Number Literals