Java Tools Tutorials - Herong's Tutorial Examples - v6.23, by Herong Yang
"jar --create" - Creating New JAR File
This section provides a tutorial example on how to create a JAR file with the 'jar --create' command.
In order to create a JAR file of Java class files, I wrote the following Java source file, Hello.java, first:
class Hello { public static void main(String[] a) { System.out.println("Hello world!"); } }
Then I compiled the Java source file to create the Java class file:
herong> javac Hello.java herong> dir Hello.* 416 Hello.class 116 Hello.java
After that I created my first JAR file, hello.jar, with Hello.class, using the "jar --create" command:
herong> jar --create --verbose --file hello.jar Hello.class added manifest adding: Hello.class(in = 416) (out= 285)(deflated 31%) herong> dir Hello.* 416 Hello.class 739 hello.jar 116 Hello.java
Notice that I used:
"jar" command also supports options written in the old short format. For example, the following two commands use option short format doing the same job as above:
herong> jar cvf hello.jar Hello.class added manifest adding: Hello.class(in = 416) (out= 285)(deflated 31%) herong> jar -c -v -f hello.jar Hello.class added manifest adding: Hello.class(in = 416) (out= 285)(deflated 31%)
Table of Contents
javac - The Java Program Compiler
java - The Java Program Launcher
JAR - Java Archive File Format
jar - JAR File Tool Command and Options
►"jar --create" - Creating New JAR File
"jar --list" - Listing Files in JAR File
"jar --extract" - Extracting Files from JAR File
Managing JAR Files with WinZIP
META-INF/MANIFEST.MF - JAR Manifest File
Adding META-INF/MANIFEST.MF to JAR Files
"jar -C" - Changing Input Directory
Using JAR Files in Java Class Paths
"jar --update" - Updating Class Files in JAR
"jar --main-class" - Making JAR File Executable
"jar --module-version" - Updating Module Version in JAR
jpackage - Binary Package Builder
javadoc - The Java Document Generator
jdeps - The Java Class Dependency Analyzer
jdeprscan - The Java Deprecated API Scanner
jcmd - The JVM Diagnostic Tool
jconsole - Java Monitoring and Management Console
jstat - JVM Statistics Monitoring Tool
jhsdb - The Java HotSpot Debugger
jvisualvm (Java VisualVM) - JVM Visual Tool
javap - The Java Class File Disassembler
keytool - Public Key Certificate Tool
jrunscript - Script Code Shell
native2ascii - Native-to-ASCII Encoding Converter