java
What is a .java file?
text/x-java-source
Java (.java) is a plain-text source file for the Java programming language — a statically typed, class-based, object-oriented language that compiles to JVM bytecode. It is widely used for enterprise back-ends, Android apps, and large systems, and emphasises explicit types and classes.
How to use a .java file
Use an example .java file to test syntax highlighters, the javac compiler, linters and formatters (Checkstyle, google-java-format), and parser or language-detection tooling.
Download example .java files
- Java — Hello WorldThe classic hello-world in Java — a public class with the standard main method — for testing highlighters, javac, and Java parsers.
- Java — Bank account (class, record, exceptions)A realistic Java class with a package declaration, fields, a nested record, methods that throw exceptions, and formatted output — for testing highlighters, javac, Checkstyle, and parsers.