Что такое формат файла JAVA?
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.
Безопасность и защита
РИСК: LOWA .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.
Детали формата
в двух словахПрограммы, открывающие файлы JAVA
Технические подробности
глубокая спецификация| MIME type | text/x-java-source (also accepted as text/x-java) |
| Text encoding | UTF-8; the default for javac since Java 18 (2022); older toolchains require an explicit -encoding flag |
| File signature | None - plain text with no magic bytes; typically opens with a package declaration, import statements, or a class definition |
| Compilation output | javac compiles each .java file into one or more .class bytecode files, one per type defined in the source |
| One public type per file | A 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 order | Optional package declaration → import statements → class, interface, enum, or record declarations containing fields and methods |
| Typical file size | 1 KB - 100 KB; a small utility class may be under 1 KB, a large class rarely exceeds 100 KB |
| Platform support | Cross-platform: Windows, macOS, Linux, and any OS with a JDK installed; the same source compiles on all platforms |
| Language version mechanism | Syntax level is not stored inside the file itself; it is controlled at compile time via javac --release N (e.g. --release 21) |
| Primitive types | Eight built-in primitives - int, long, double, float, boolean, char, byte, short - exist alongside object types |
| Modern syntax additions | Records (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 packaging | Multiple compiled .class files are bundled into a .jar archive for distribution and execution on any JVM |
| Language stewardship | Java language specification maintained by Oracle; open-source implementation via OpenJDK under the Java Community Process (JCP) |
| Common development tools | IntelliJ IDEA, Eclipse IDE, and Visual Studio Code (with the Java Extension Pack) provide full language tooling for .java files |
| Выпущен | 1995 (Java 1.0, Sun Microsystems) |
| Последняя версия | Tracks the Java language version; Java 24 (2025) is current at time of writing |
| Открыть стандартное | Да · без роялти |
| Спецификация | docs.oracle.com |
Конвертации JAVA
Вопросы и ответы сообщества
спрошено пользователямиВопросов пока нет - станьте первым, кто спросит о файлах JAVA.