.class File Extension

Learn what a .class file contains, how to inspect Java bytecode safely, how Poly supports it, and when to keep source or use a JAR instead.

File extension details for .class

Storage Only
File typeJava Virtual Machine class file
MIME type
EncodingBinary JVM class-file format, big-endian
Operating systemsWindows, macOS, Linux
Opens withjavap, IntelliJ IDEA, Java Virtual Machine
Poly supportYes. Poly stores, syncs, shares, and versions class files.
Indexed by PolyPartial. Poly indexes the filename and basic file properties, not bytecode or symbols.
Preview in PolyNo. Class files do not have an in-app content preview.
Poly agentNo. The Poly agent cannot read compiled class contents.

What kind of file is a .class?

A .class file contains compiled instructions for the Java Virtual Machine (JVM). It is binary bytecode, not the human-readable Java source found in a .java file. A class file usually represents one class or interface and can include a constant pool, fields, methods, and attributes.1

The usual de facto media types are application/java and application/java-vm. Neither is registered by IANA for class files.2 The first four bytes should be CA FE BA BE, followed by minor and major class-file version numbers. That signature is useful, but it is not conclusive by itself because a big-endian universal Mach-O binary can begin with the same four bytes. A parser must validate the remaining structure.1

Renaming Java source, a JAR, or another binary to .class does not compile or convert it. Use javac to compile source and inspect the resulting file's contents before trusting its suffix.

How do I open a .class on my computer?

Install a Java Development Kit on Windows, macOS, or Linux, then inspect the file without executing it:

  • Run javap -verbose Example.class to see version information, the constant pool, fields, methods, and attributes. Add -c for bytecode instructions.3
  • Open it in IntelliJ IDEA for a decompiled, Java-like view.4
  • Use a bytecode analysis tool when you need programmatic inspection or comparison.

Decompiler output is an approximation. Compilation removes comments and formatting, while obfuscation or generated code can make recovered source hard to read. To run a class, use the java launcher with the correct class name and class path. Double-clicking an arbitrary file is neither a reliable nor a safe test.

Poly support for .class

Poly stores, syncs, shares, versions, and finds .class files by name and basic properties. It does not currently extract class names, methods, annotations, constant-pool strings, or bytecode. There is no content preview, and the Poly agent cannot interpret the compiled contents.

Keep the corresponding .java source or a trusted javap report beside the binary when you want full-text search or agent-readable context.

History of .class

The extension arrived with the original Java platform and its portable JVM format. Instead of compiling separately for every processor, Java compilers emit a hardware-independent class representation for a compatible JVM to load.1

The version fields evolved with the platform:

Java releaseClass-file major version
Java 852
Java 1761
Java 2569

An older JVM generally cannot load a class produced for a newer release. The compiler's --release option can target an older supported Java API and class-file version when compatibility matters.5

Working with .class and alternatives

Choose the artifact that matches your goal:

  • Keep .java source, build files, and dependency information for maintenance and review.
  • Package multiple class files and resources in a JAR for distribution. A JAR uses application/java-archive and is ZIP-based, so changing the suffix does not create one.
  • Use javap or a decompiler for inspection, not as a lossless route back to the original source.
  • Recompile with an appropriate target release when an older JVM reports an unsupported class-file version.
A class file contains executable instructions. Do not run an untrusted one merely to identify it. Inspect it with static tools first, and use an isolated environment if execution is necessary. JVM verification checks structural and type-safety rules, not whether the program's intended behavior is benign.6

Footnotes

  1. Oracle. The Java Virtual Machine Specification: The class File Format. 2 3
  2. Internet Assigned Numbers Authority. Media Types Registry. The registry includes application/java-archive, but not a class-file media type.
  3. Oracle. The javap Command.
  4. JetBrains. Bytecode Decompiler.
  5. Oracle. The javac Command.
  6. Oracle. Verification of class Files.
© Poly Corp. 2026