Java source code file (Java file) – .java

– contains the source java code

Java class file – .class

– contains java bytecode that will be executed by the JVM

– produced by running compiling the java code using javac javacodefilename.java

– only works if the java source code file contains classes

– just need the compiled class file to run program

JAR file – .jar

– essentially a ZIP file usually containing java bytecode, sourcecode, config files, etc.

– contains a Manifest file that describes some meta data about the files in the JAR

– commands:

– you can execute a JAR with: java -jar jarfile.jar

– create a JAR file: jar -cf jarfile.jar <input files>;

– examine contents of a JAR file: jar -tf jarfile.jar

– extract contents of a JAR file: jar -xf jarfile.jar

– for specific files JAR file: jar -xf jarfile.jar

Manifest file – MANIFEST.MF

– describes ‘meta’ information above the files contained in a JAR

– uses “header” “value” pairs separated by newlines

– ex. Manifest-Version: 1.0

=> Created-By: 1.2.45 (pooop)

– can do things like specify an application’s entry class/point, adding to the classpath (specifies user defined classes and packages, setting version info, etc.

– Autogenerated in a META-INF/ folder in the JAR file

– to modify the Manifest file in a JAR file, use the -m option

– ex. I want to add a list of header value pairs that override some and add some pairs to the manifest file. The file with these new values is called ‘manitest’:

I run: jar -cvfm jarfile.jar manitest <input files>