.JAVA

JAVA File

Java source code file
Ask a question
QUICK ANSWER

A JAVA file is human-readable source code written in the Java programming language. Open it in any text editor or a Java IDE such as IntelliJ IDEA or VS Code. To run it, install a JDK, then compile with "javac App.java" and run with "java App"; on JDK 11+ you can also run it directly with "java App.java".

Developer: Sun Microsystems (now Oracle); the Java language is governed via the Java Community Process / OpenJDK Category: Developer Files Open standard MIME: text/x-java-source
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 17, 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 JAVA file format?

A .java file is a plain-text source code file written in the Java programming language. Java is an object-oriented programming language built around the concepts of classes and objects. .java source files are compiled by the javac compiler into .class bytecode files; to run the resulting program, a Java Virtual Machine (JVM) is required. Java is also the primary language used for developing Android applications.

Object-oriented programming

Java was heavily influenced by C++, though it was designed from the ground up as a platform-independent language. The original designers accepted some trade-offs in raw execution speed in order to achieve "write once, run anywhere" portability; modern JIT (just-in-time) compilation has since closed much of that gap. .java files are built almost entirely from class, interface, enum, and record declarations, with only a small set of primitive types (such as int, boolean, and double) falling outside the object model. By convention, each .java file contains exactly one public type, and the file name must match that type's name - for example, App.java must contain public class App.

For simplicity, a class is a generalization - a template - of an object:

  • *Class:* human - *object:* Smith John
  • *Class:* airplane - *object:* Boeing 737

Each class defines the properties an object can have (for example, a car may have properties such as color, number of seats, etc.) and the methods it can execute - that is, the operations or actions it can perform (for example, a car object can accelerate, brake, and sound a horn). Classes can inherit from other classes or compose other classes, enabling code reuse and modular design.

Compiling a .java file with javac produces a .class file; multiple .class files are commonly packaged into a JAR archive for distribution. Since Java 11, a single-file .java program can also be launched directly with the java command without an explicit compile step.

Security & safety

RISK: LOW

A .java file is passive source text - opening or reading it cannot harm your computer. The risk appears only if you COMPILE and RUN it: like any program you build from someone else's code, it then executes with your permissions and could do anything the code says, so review or trust the source before running 'javac'/'java'. There is no auto-execution from merely viewing the file in an editor.

Format details

in a nutshell
FULL NAMEJava source code fileaka Java source file, Java class source
DEVELOPERSun Microsystems (now Oracle); the Java language is governed via the Java Community Process / OpenJDKsince 1995 (Java 1.0, Sun Microsystems)
MIME TYPEtext/x-java-source
TYPEPlain-text source code in the Java programming language (text)
STANDARDOpen · royalty-free

Programs that open JAVA files

Windows5 apps
Eclipse IDE Open-source Import into a project to edit, compile and run the code.
Notepad Open-source Open to view/edit the source with syntax highlighting (does not compile it).
IntelliJ IDEA (Community) Freemium Open the file or its project; full Java IDE with run/compile, the most popular choice for Java development.
Visual Studio Code (+ Java Extension Pack) Free Open the .java; install the 'Extension Pack for Java' to compile, run and debug.
JDK (javac / java) Open-source To compile and run: install a JDK (OpenJDK/Temurin), then 'javac App.java' and 'java App' (or 'java App.java' to run a single file directly).
macOS3 apps
IntelliJ IDEA (Community) Freemium Open the file/project to edit, compile and run on macOS.
Visual Studio Code (+ Java Extension Pack) Free Open and edit; add the Java pack to compile/run/debug.
JDK (javac / java) Open-source Install Temurin, then 'javac App.java' / 'java App' in Terminal.
Linux3 apps
Visual Studio Code / IntelliJ IDEA Free Open and edit the source; both run on Linux with full Java tooling.
GNU Emacs / Vim / gedit Open-source View/edit the .java as text in any of these editors.
JDK (javac / java - OpenJDK) Open-source Install 'default-jdk' or Temurin, then 'javac App.java' and 'java App'.

Technical details

deep spec
MIME typetext/x-java-source (also accepted as text/x-java)
Text encodingUTF-8; the default for javac since Java 18 (2022); older toolchains require an explicit -encoding flag
File signatureNone - plain text with no magic bytes; typically opens with a package declaration, import statements, or a class definition
Compilation outputjavac compiles each .java file into one or more .class bytecode files, one per type defined in the source
One public type per fileA public type's name must match the file name exactly - e.g. App.java must declare public class App; violating this is a compile error
File structure orderOptional package declaration → import statements → class, interface, enum, or record declarations containing fields and methods
Typical file size1 KB - 100 KB; a small utility class may be under 1 KB, a large class rarely exceeds 100 KB
Platform supportCross-platform: Windows, macOS, Linux, and any OS with a JDK installed; the same source compiles on all platforms
Language version mechanismSyntax level is not stored inside the file itself; it is controlled at compile time via javac --release N (e.g. --release 21)
Primitive typesEight built-in primitives - int, long, double, float, boolean, char, byte, short - exist alongside object types
Modern syntax additionsRecords (Java 16), sealed classes (Java 17), pattern matching for switch (Java 21), unnamed patterns and variables (Java 22)
Direct launch (Java 11+)A single-source .java file can be run with java FileName.java without a prior javac compile step
Deployment packagingMultiple compiled .class files are bundled into a .jar archive for distribution and execution on any JVM
Language stewardshipJava language specification maintained by Oracle; open-source implementation via OpenJDK under the Java Community Process (JCP)
Common development toolsIntelliJ IDEA, Eclipse IDE, and Visual Studio Code (with the Java Extension Pack) provide full language tooling for .java files
Released1995 (Java 1.0, Sun Microsystems)
Latest versionTracks the Java language version; Java 24 (2025) is current at time of writing
Open standardYes · royalty-free
Specificationdocs.oracle.com

JAVA conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with JAVA 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 JAVA files.

Frequently asked questions

How do I open a .java file?
It's plain text - any editor opens it (Notepad++, VS Code). To work with it properly, use a Java IDE like IntelliJ IDEA (Community) or Eclipse, which add highlighting and let you compile and run the code.
How do I run a .java file?
Install a JDK (free OpenJDK/Temurin), then compile and run: 'javac App.java' creates App.class, and 'java App' runs it. On modern JDKs you can also run a single file directly with 'java App.java'.
What's the difference between .java, .class and .jar?
.java is the human-written source code; compiling it with javac produces .class bytecode; many .class files are bundled into a .jar to distribute a whole program. You edit .java, the JVM runs .class, and you ship .jar.
Do I need the full JDK or just Java to open a .java file?
To merely view/edit it, neither - any text editor works. To compile and run it you need a JDK (which includes javac); the consumer 'java.com' runtime only runs compiled bytecode, not source.
Can I turn a .java file into an .exe or an Android .apk?
Not directly. For Windows you compile to a JAR and wrap it (jpackage/Launch4j) - the result still needs Java. For Android you need a full project built into an APK by Android Studio; a single .java file can't become an APK.
Why does my .java file fail to compile with a 'class ... is public, should be declared in a file named ...' error?
Java requires a public top-level type's name to match the file name. Rename the file to match the public class (e.g. App.java for 'public class App'), or make the class non-public.

References

1Oracle - Java Language and VM Specificationsdocs.oracle.com
2Oracle - Getting Started / compiling and runningdev.java

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.PARTPartial Download File
4.MDMarkdown Document
5.RPMSGRestricted Permission Message
6.CRDOWNLOADChrome Partial Download File
7.NOMEDIAAndroid No-Media Marker File
8.PRDXSoftMaker Presentations Document
9.PRO6XProPresenter 6 Bundle File
10.SWFSmall Web Format (Shockwave Flash)

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