Java Tools Tutorials - Herong's Tutorial Examples - v6.24, by Herong Yang
"jar --update" - Updating Class Files in JAR
This section provides a tutorial example on how to 'jar --update' to update class files in JAR files.
If you have an existing JAR file, you can use the "jar --update" command to update (add or replace) class files in the JAR file.
Here is what I did to add F2C.class to herong.jar:
herong> jar --update --verbose --file herong.jar F2C.class herong> jar --list --verbose --file herong.jar 0 ... EDT 2018 META-INF/ 66 ... EDT 2018 META-INF/MANIFEST.MF 0 ... EDT 2018 com/ 0 ... EDT 2018 com/herongyang/ 806 ... EDT 2018 com/herongyang/TempratureConvertorBean.class 1208 ... EDT 2018 F2C.class
Note that F2C.class is stored in the root directory of the JAR file, since it is an un-named package class.
Now I can move herong.jar to any where, and run the F2C class from the JAR file:
herong> del F2C.class herong> java -classpath herong.jar F2C 70 Fahrenheit = 70.0 Celsius = 21.11111111111111 My TempraturConvertorBean - Version 1.00
Basically, a JAR file is a container of Java class files.
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