JAR File - What It Is & How to Open One

JAR File - What It Is & How to Open One

A JAR (Java ARchive) file is a package file format, based on the ZIP file format, used to aggregate many Java class files, metadata and resources (text, images, etc.) into one file for distribution.1

The contents of a JAR file can be extracted using any standard decompression tool, or the jar command line utility.

unzip

unzip -d foo foo.jar
Parameters
  • -d <dir>: extract files into dir.

jar

jar -xf foo.jar
Parameters
  • -x: extract named (or all) files from archive.
  • -f <file>: specify archive file name.

Decompile Class Files

Java class files are compiled files containing Java bytecode that can be executed by a Java Virtual Machine (JVM). To decompile and view the source code in plain text any Java decompiler can be used. JAD was the go-to for many years but only supports Java 1.4 or below. The Java-Decompiler Project, Procyon, and online tools like DevToolZone’s Java Decompiler are good alternatives.

procyon

procyon foo.class

  1. “JAR File Specification.” JAVA SE Documentation, https://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JARIndex. ↩︎