Java Class File MIME Type
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 type | application/java |
|---|---|
| Extensions | .class |
| Magic number | CA FE BA BE |
| Alternate versions | application/java-vm |
| First standardized | 1996 |
| Created by | Sun Microsystems |
| Browser support | |
| Example applications | javap, IntelliJ IDEA |
| Poly support | Partial. Poly recognizes .class files as application/java and stores them, but does not parse their bytecode or class metadata. |
| Indexed by Poly | Partial. Poly indexes the filename and file properties, but not bytecode, symbols, methods, or embedded strings. |
| Preview in Poly | No. application/java files do not have an in-app content preview. |
| Poly agent | No. 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.4Java source, class files, JARs, and serialized objects
Several Java-related files are easy to confuse, but they are not interchangeable:
| Content | Usual extension | Media type commonly used | What it contains |
|---|---|---|---|
| Java source | .java | text/x-java-source or a text type | Human-readable declarations and code |
| JVM class file | .class | application/java or application/java-vm | Compiled bytecode for one class or interface |
| Java archive | .jar | application/java-archive | A ZIP-based package of classes, resources, and a manifest |
| Serialized Java object | .ser | application/java-serialized-object | Object 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:
| Offset | Size | Meaning |
|---|---|---|
0x00 | 4 bytes | Magic number CA FE BA BE |
0x04 | 2 bytes | Minor version |
0x06 | 2 bytes | Major 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
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.6How 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
javapcommand displays class declarations and can disassemble bytecode.6 - IntelliJ IDEA includes a bytecode decompiler that presents a compiled
.classfile 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
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
- Oracle. The Java Virtual Machine Specification, Java SE 25 Edition: Introduction. ↩ ↩2
- Oracle. The Java Virtual Machine Specification, Java SE 25 Edition: The class File Format. ↩ ↩2
- Internet Assigned Numbers Authority. Media Types Registry. ↩
- Oracle. Sun Java System Web Server: MIME Types. ↩
- Oracle. The javac Command. ↩
- Oracle. The javap Command. ↩ ↩2
- JetBrains. IntelliJ IDEA Bytecode Decompiler. ↩
- Oracle. Verification of class Files. ↩
- Oracle. Java Object Serialization Specification: Stream Protocol. ↩