Java Class File MIME Type

Learn how application/java identifies compiled Java class files, how to inspect them safely, and what Poly supports.

MIME type details for application/java

In active use
MIME typeapplication/java
Extensions
.class
Magic numberCA FE BA BE
Alternate versions
application/java-vm
First standardized1996
Created bySun Microsystems
Browser support
Example applicationsjavap, IntelliJ IDEA
Poly supportPartial. Poly recognizes .class files as application/java and stores them, but does not parse their bytecode or class metadata.
Indexed by PolyPartial. Poly indexes the filename and file properties, but not bytecode, symbols, methods, or embedded strings.
Preview in PolyNo. application/java files do not have an in-app content preview.
Poly agentNo. The Poly agent cannot read or reason about the compiled class contents.

What does application/java represent?

In Poly, application/java identifies a compiled Java Virtual Machine class file with the extension .class. A class file is binary bytecode, not the human-readable Java source stored in a .java file. The Java Virtual Machine Specification describes it as a hardware-independent representation of one compiled class or interface, containing JVM instructions, a constant pool, fields, methods, and attributes.1

Every class file begins with the four bytes CA FE BA BE. The next four bytes hold its minor and major class-file version, so checking only the extension is unnecessary. A valid file has both the signature and a version supported by the intended JVM.2

application/java is used by Poly, but it is not an IANA-registered media type. The IANA registry lists application/java-archive for JAR files, but no application/java entry.3 Sun's Java System Web Server documentation used application/java-vm for .class files, which is why that label is also common.4

Java source, class files, JARs, and serialized objects

Several Java-related files are easy to confuse, but they are not interchangeable:

ContentUsual extensionMedia type commonly usedWhat it contains
Java source.javatext/x-java-source or a text typeHuman-readable declarations and code
JVM class file.classapplication/java or application/java-vmCompiled bytecode for one class or interface
Java archive.jarapplication/java-archiveA ZIP-based package of classes, resources, and a manifest
Serialized Java object.serapplication/java-serialized-objectObject state written using Java serialization

The javac compiler reads .java source and emits .class files that run on a JVM. One source file can produce more than one class file, such as separate outputs for nested classes.5 A JAR normally bundles many class files and resources, so renaming a lone .class file to .jar does not create a Java archive.

How to identify a Java class file

The first eight bytes are the most useful quick check:

OffsetSizeMeaning
0x004 bytesMagic number CA FE BA BE
0x042 bytesMinor version
0x062 bytesMajor version

The format then continues with the constant pool, access flags, class and superclass references, interfaces, fields, methods, and attributes. Integer fields are stored in big-endian order.2

Class-file versions matter for compatibility. Java 1.0.2 used major version 45, Java 8 used 52, Java 17 used 61, and Java 25 uses 69. A newer class file generally will not load on an older JVM that does not support its major version. Preview-feature class files also use a special minor version and are tied to the corresponding Java release.1

Run javap -verbose Example.class to inspect the signature, class-file version, constant pool, methods, and attributes without launching the program. Add -c when you want a bytecode disassembly.6

How to open an application/java file

A web browser does not render a .class file as a page. Use a development or analysis tool instead:

  • The JDK's javap command displays class declarations and can disassemble bytecode.6
  • IntelliJ IDEA includes a bytecode decompiler that presents a compiled .class file as Java-like source.7
  • Binary-analysis libraries and JVM tooling can inspect the class structure programmatically.

Decompiled output is an approximation. Compilation can discard comments, formatting, and some source-level choices, while optimizations and generated constructs can make the result differ from the original source.

To run an application, use its documented entry point and class path. The java launcher expects a main class name, not merely an arbitrary .class filename. Many real applications are distributed as JARs or modules because a single class rarely contains all of their dependencies.

Support in Poly

Poly recognizes the .class extension and assigns application/java. It stores, syncs, shares, versions, and searches these files like other binary files. Its current implementation categorizes Java class files as an unknown binary media type, however, so the format-specific experience is limited:

  • Poly indexes the filename and ordinary file properties.
  • It does not extract the constant pool, class name, methods, annotations, or embedded strings.
  • It does not generate a thumbnail or content preview.
  • The Poly agent does not receive or interpret the bytecode contents.

If you need content search or an agent-readable representation, keep the corresponding .java source or a trusted javap report alongside the class file.

Security and safe inspection

A .class file contains executable instructions. Treat an unknown class file as code, not as a passive document. The JVM verifies structural and type constraints when linking classes, but verification is not a promise that the program's intended behavior is safe. The JVM specification explicitly accounts for class files that may have been produced by an adversary.8

Do not execute an untrusted class merely to find out what it does. Inspect it with javap, a decompiler, hashes, and malware-analysis controls first. If execution is necessary, use an isolated environment with no secrets, personal files, or production credentials.

Also avoid confusing a class file with a Java serialized object. Their signatures differ: a class file begins CA FE BA BE, while a standard serialization stream begins AC ED. Deserializing untrusted object streams creates a separate class of risks and is not required to inspect a .class file.9

Can a .class file be converted back to .java?

A decompiler can produce readable Java-like source, but it cannot guarantee the original .java file. Names may be missing or obfuscated, comments are absent, and several source constructs can compile to similar bytecode. Treat decompiled output as an aid for understanding and interoperability, not a lossless conversion.

If your goal is distribution, package class files and required resources with the JDK's jar tool or your build system. If your goal is long-term maintenance, preserve the original source, build configuration, dependency lock information, and target Java release rather than relying on class files alone.

Footnotes

  1. Oracle. The Java Virtual Machine Specification, Java SE 25 Edition: Introduction. 2
  2. Oracle. The Java Virtual Machine Specification, Java SE 25 Edition: The class File Format. 2
  3. Internet Assigned Numbers Authority. Media Types Registry.
  4. Oracle. Sun Java System Web Server: MIME Types.
  5. Oracle. The javac Command.
  6. Oracle. The javap Command. 2
  7. JetBrains. IntelliJ IDEA Bytecode Decompiler.
  8. Oracle. Verification of class Files.
  9. Oracle. Java Object Serialization Specification: Stream Protocol.
© Poly Corp. 2026