What is a .java file?
Java Source File · Code and data · Sun Microsystems / Oracle · 1995
A .java file is Java source code, a widely used language that compiles to bytecode and runs on the Java Virtual Machine. It powers Android apps, enterprise back ends and large-scale systems.
What is a .java file used for?
Java source is compiled by javac into .class files of bytecode, which the JVM runs on any platform. This write-once, run-anywhere design made Java a mainstay of enterprise software.
Android apps were traditionally written in Java, and much server software still is. The files are plain text; IntelliJ IDEA, Eclipse and VS Code are common editors.
What opens a .java file?
The .java format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list.
Windows
- IntelliJ IDEA
- Eclipse
- VS Code
macOS
- IntelliJ IDEA
- Eclipse
- VS Code
Linux
- IntelliJ IDEA
- Eclipse
- VS Code
Open a .java file step by step
- Confirm the file really is a .java. Drop it into the WhatFileType identifier, which reads its signature in your browser without uploading anything.
- On Windows, open it with IntelliJ IDEA or Eclipse.
- On Mac, use IntelliJ IDEA or Eclipse.
- On Linux, try IntelliJ IDEA or Eclipse.
- Still stuck? Convert the .java to class (bytecode), which opens more widely.
Why can't I open my .java file?
Almost always because no installed app understands Java. Install one of the apps above, or convert the file to a format your existing software already reads. If double-clicking opens the wrong program instead of nothing at all, the file association is set to the wrong app rather than the file being broken.
The other possibility is that the file is not really a .java at all. Drop it into the file identifier to check it by its bytes instead of its name. Nothing is uploaded.
How to convert a .java file
You can convert a .java file to class (bytecode), jar using a conversion tool or the export menu of an app that opens it.
Java has no fixed magic number, so there is no signature table on this page. Its bytes alone do not prove the format: identification relies on the extension, the structure of the content and the program that created it. The magic-numbers reference lists the formats that do carry one.
Frequently asked questions
What is a .java file?
A .java file is Java source code, a widely used language that compiles to bytecode and runs on the Java Virtual Machine. It powers Android apps, enterprise back ends and large-scale systems.
How do I compile and run a .java file?
Compile with javac File.java to make File.class, then run java File. Modern JDKs can also run a single file directly with java File.java.
What is the difference between .java and .class?
A .java file is human-readable source. javac compiles it into a .class file of bytecode that the Java Virtual Machine executes.
How do I open a .java file?
Any text editor works. IntelliJ IDEA, Eclipse or VS Code add highlighting, building and debugging.
Related formats
Sources
Details on this page were checked against authoritative references. How sources are ranked and what is deliberately left out is set out in the methodology.