Jar Files (Wiki forum at Coderanch) (original) (raw)
posted 9 years ago
1
Number of slices to send:
Optional 'thank-you' note:A Java ARchive(JAR) file is used to group java class files and other files needed for an application. It is a zip file with different extension, and thus one can create/view/modify with zip utilities such as winzip.
Short for Java ARchive, a platform independent file format used to bundle multiple files into a single archive file. Typically a JAR file will contain the class files and auxiliary resources associated with applets and applications. However, a JAR file could contain libraries and extensions to the Java language itself, entire Java Applications, or Java utility code. By convention, JAR files end with a .jar extension.
A JAR file can also contain a manifest that includes archive content metadata, such as which class in the archive contains the main method to be used when treating the jar file as an executable.
A JAR file can be made executable, i.e. started by double-clicking it. See here and here for more information.
How do I make a .jar of my Java program?
First compile your java file(s) using javac command. Example javac HelloWorld.java will generate HelloWorld.class
Then use jar command. Example jar cvf Hello.jar HelloWorld.class .(Type jar to see various archive options)