.CLASS

CLASS File

Java Bytecode Class File
Ask a question
QUICK ANSWER

A CLASS file is compiled Java bytecode - the output javac produces from a .java source file. To run it you need Java (a JDK) installed, then use the command "java MyClass". To read what the code does, open it in a decompiler such as JD-GUI. CLASS files are not documents; double-clicking one in a file manager will not open it usefully.

Developer: Sun Microsystems (now Oracle); part of the Java Platform Category: Developer Files Open standard MIME: application/java-vm
OPENS ON Windows macOS Linux Web
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 31, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the CLASS file format?

A .class file contains compiled source code written in the Java programming language. .class files are generated by the Java compiler from .java source files that define one or more classes. Each .class file is the result of a successful compilation and holds bytecode - a binary representation of a class that is executed by the Java Virtual Machine (JVM).

.class files are generated automatically during the compilation of .java source files. Because bytecode is platform-independent, the same .class file runs on any operating system that has a compatible JVM installed. A single .java source file can hold one or more classes, and each class gets its own .class file during the compilation process.

Compilation of .java files into .class files is performed using the javac command included with the Java Development Kit (JDK). Most Java programming environments - including IDEs such as IntelliJ IDEA and Eclipse - compile .class files automatically as programmers write code.

The Java Runtime Environment (JRE) supports execution of .class files via the java command, but does not allow compilation since the JRE does not include the javac compiler.

Every .class file begins with the 4-byte magic number 0xCAFEBABE, followed by minor and major version fields that identify the Java release used to compile it. Multiple .class files are commonly packaged together into a JAR archive for distribution and deployment.

Because the JVM is available in many versions, one must keep in mind that not all .class files are compatible with all versions of the runtime. A file compiled targeting a newer Java major version cannot be loaded by an older JVM.

Security & safety

RISK: MEDIUM

A .class is compiled code: if you run it ('java MyClass') with a JVM, it executes with your user's permissions, so an unknown class - like an unknown JAR or EXE - can carry malware. Treat downloaded compiled Java as untrusted: only run classes from a source you trust. Merely decompiling or disassembling a .class (JD-GUI, javap) does not execute it and is safe. Be aware that bytecode reveals a program's logic, so anything you compile can be decompiled by others unless obfuscated.

Format details

in a nutshell
FULL NAMEJava Bytecode Class File
DEVELOPERSun Microsystems (now Oracle); part of the Java Platformsince 1995-1996 (Java 1.0)
MIME TYPEapplication/java-vm
TYPECompiled Java bytecode (binary)
STANDARDOpen · royalty-free
MAGIC BYTES · FILE SIGNATURE
OFFSET
00010203
HEX
CAFEBABE
ASCII
····
Every Java class file begins with the 4-byte magic number 0xCAFEBABE, followed by a 2-byte minor and 2-byte major version (the major version tells you which Java release compiled it, e.g. 52 = Java 8, 61 = Java 17). This makes .class files trivially identifiable. (Note: Mach-O fat binaries on macOS use 0xCAFEBABE too, but Java class files are distinguished by the version words that follow.)

Programs that open CLASS files

Windows4 apps
Eclipse IDE Open-source Import the class into a project to run it, or use the bundled bytecode/decompiler view to inspect it.
Java (OpenJDK - Eclipse Temurin / Adoptium) Open-source Install Temurin JDK, then run the class from its package root: 'java MyClass' (no .class extension). Needs a main method.
JD-GUI (decompiler) Open-source Open the .class (or a JAR) to view reconstructed Java source - the practical way to read what a .class does.
IntelliJ IDEA (Community) Freemium Open/drag a .class - IntelliJ shows a built-in decompiled view and can run classes in a project.
macOS3 apps
Java (OpenJDK - Eclipse Temurin) Open-source Install Temurin, then 'java MyClass' in Terminal from the right directory.
JD-GUI (decompiler) Open-source Open the .class to read its decompiled source on macOS.
IntelliJ IDEA (Community) Freemium Open a .class for the built-in decompiled view, or run it inside a project.
Linux2 apps
Java (OpenJDK) Open-source Install via package manager ('apt install default-jdk') or Temurin, then 'java MyClass'.
JD-GUI / CFR (decompilers) Open-source CFR is a command-line decompiler ('java -jar cfr.jar MyClass.class'); JD-GUI is the GUI option.
Web1 app
javap (bundled with the JDK) Built-in Not web - but the JDK's 'javap -c MyClass' disassembles a .class to readable bytecode without any extra tool.

Technical details

deep spec
Format typeCompiled Java bytecode (binary)
MIME typeapplication/java-vm
Magic bytes0xCAFEBABE (4 bytes at file offset 0) - present in every valid .class file
Version encodingBytes 6-7 (major version) identify the target Java release; e.g., 52 = Java 8, 61 = Java 17, 65 = Java 21
Execution environmentJava Virtual Machine (JVM) via the `java` command
Compilation tool`javac` compiler, included in the Java Development Kit (JDK)
Platform independenceBytecode is CPU-architecture-neutral and runs on any OS with a compatible JVM
One class per fileEach top-level or static nested class compiles to its own separate `.class` file
Inner class namingInner and anonymous classes produce additional files with `$` in the name (e.g., `Outer$Inner.class`)
Constant poolEach file embeds a structured constant pool table holding string literals, class names, and field/method descriptors
Instruction setUses the JVM bytecode instruction set (~200 opcodes), independent of any native CPU instruction set
Bytecode verifierThe JVM verifies `.class` file structure and type safety before execution, rejecting malformed or tampered files
DecompilationCan be disassembled with `javap -c` (JDK built-in) or decompiled back to Java source with tools such as JD-GUI or CFR
PackagingTypically distributed bundled inside `.jar` archives (ZIP-based containers holding multiple `.class` files and a manifest)
Android incompatibilityAndroid does not execute `.class` files directly; the `d8` tool converts them to `.dex` bytecode for the Android Runtime (ART)
Released1995-1996 (Java 1.0)
Open standardYes · royalty-free
Specificationdocs.oracle.com

CLASS conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with CLASS files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about CLASS files.

Frequently asked questions

How do I open a CLASS file?
You don't open it like a document - it's compiled Java. To RUN it you need Java (JDK) installed, then 'java MyClass'. To READ what it does, open it in a decompiler such as JD-GUI, or disassemble it with the JDK's 'javap -c MyClass'.
How do I decompile a .class file back to Java source?
Use a decompiler - JD-GUI (drag the .class in), or command-line CFR/Fernflower/Procyon. You'll get readable Java, but comments and original variable names are usually gone, and obfuscated classes come out messy.
Why do I get 'UnsupportedClassVersionError'?
The class was compiled with a newer Java than the one you're running. Install a JDK at least as new as the one that built it (the class's major version: 52=Java 8, 61=Java 17, 65=Java 21), or recompile the source for your version.
Do I need Java to open a CLASS file?
To run it, yes - it needs a JVM. To read/decompile it, you can use tools like JD-GUI; the IntelliJ/JD-GUI viewers still rely on Java to run themselves, so in practice you'll have Java installed either way.
Can I convert a CLASS file to an EXE?
Not directly - a .class needs a JVM and isn't native Windows code. Package the classes into a runnable JAR and wrap it with jpackage or Launch4j; the result still relies on (or bundles) Java.
What's the difference between a .class and a .jar file?
A .class is one compiled class; a JAR is a ZIP bundle of many .class files plus a manifest, used to ship a whole program or library. Real applications are distributed as JARs, not loose .class files.

References

1Oracle - The Java Virtual Machine Specification, Ch.4: The class File Formatdocs.oracle.com
2Oracle - javap tool (class disassembler)docs.oracle.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.MDMarkdown Document
3.CRDOWNLOADChrome Partial Download File
4.BINCD/DVD Disc Image (BIN/CUE)
5.PARTPartial Download File
6.RPMSGRestricted Permission Message
7.NOMEDIAAndroid No-Media Marker File
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.ICSiCalendar data file

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z