Creating the First JAR File - hello.jar

This section provides a tutorial example on how to create a JAR file with the 'jar' command.

To create my first JAR file, I wrote the following Java file, Hello.java:

class Hello {
   public static void main(String[] a) {
      System.out.println("Hello world!"); 	
   }
}

Here is what I did in a command window to create and extract my first JAR file, hello.jar:

C:\herong>javac Hello.java

C:\herong>jar cvf hello.jar Hello.class
added manifest
adding: Hello.class(in = 416) (out= 285)(deflated 31%)

C:\herong>jar tf hello.jar
META-INF/
META-INF/MANIFEST.MF
Hello.class

>del Hello.class

C:\herong>jar xvf hello.jar
  created: META-INF/
extracted: META-INF/MANIFEST.MF
extracted: Hello.class

C:\herong>dir Hello.class
   416 Hello.class

C:\herong>type meta-inf\manifest.mf
Manifest-Version: 1.0
Created-By: 1.8.0 (Oracle Corporation)

What happened here is that:

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

'jar' - The JAR File Tool

 JAR - Java Archive File Format

 'jar' - JAR File Tool Command and Options

Creating the First JAR File - hello.jar

 Managing JAR Files with WinZIP

 META-INF/MANIFEST.MF - JAR Manifest File

 Adding META-INF/MANIFEST.MF to JAR Files

 Using JAR Files in Java Class Paths

 Creating Executable JAR Files

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version