Codectionary / Developer documentation / Java

Start here to learn what Java is, why it was created, how Java programs run and where developers use it today.

File extension
.java
Runs in
Java Virtual Machine

What Java is

Java is a general-purpose programming language used to write applications, services and tools. A Java source file usually ends in .java. The language describes the rules for writing code; the Java Development Kit (JDK) supplies the tools to build it. The Java Virtual Machine (JVM) is the execution environment for the usual compiled form of a Java application.

Java is statically typed: the compiler checks that values and operations fit declared types before a program runs. It supports object-oriented programming, which groups data and behaviour into classes and objects, but you can also write ordinary methods, work with primitive values and use functional features such as lambdas. You do not need to master all these styles to print a first line of text.

Why Java was created

James Gosling and colleagues at Sun Microsystems developed Java from work on the Green project in the early 1990s. The language was first called Oak and was designed for software that could run across different consumer devices. Sun publicly introduced Java in 1995, when the growing web gave its portability a much larger audience. Oracle acquired Sun Microsystems in 2010 and now stewards Oracle JDK; the open-source OpenJDK project is a key place where Java platform work continues.

Java has evolved through many releases, adding stronger libraries, generics, lambdas, modules and other features. New feature releases and long-term support (LTS) releases serve different needs. As of October 2026, Java 27 is the current feature release and Java 25 is the latest LTS release on Oracle’s roadmap. Always check the current roadmap and your project’s requirements before installing; an existing application may deliberately target an older supported JDK.

What “write once, run anywhere” means

The usual workflow compiles Java source into bytecode in a .class file. A compatible JVM on another operating system can execute that bytecode without recompiling the source for that operating system. This is a useful kind of portability, especially for server applications deployed on several platforms.

Portability still has conditions. A program needs a suitable Java version and its dependencies, and operating-system-specific code or native libraries can make it less portable. Java source is not normally executed directly by a web browser, and Java is a different language from JavaScript despite the similar name.

Java and JavaScript are different languages

Java and JavaScript have separate syntax rules, tools and common execution environments. A typical Java application is compiled for a JVM; JavaScript is the language browsers run to make webpages interactive, and it also runs in server runtimes such as Node.js. Their names reflect 1990s naming history, not a parent-child relationship. Learning one does not automatically mean you know the other.

Where Java is used

Enterprise, backend and web applications: Java can handle requests, validate data and coordinate with databases. Frameworks such as Spring provide HTTP routing and other application features; those features are not built into the Java language itself. A booking service, for example, could use Java to check availability and return a reservation result through an API.

APIs, microservices and distributed systems: teams use Java to build services that communicate across a network. A microservice is a separately deployed service with a focused responsibility, not a special Java feature. Java’s libraries, concurrency tools and monitoring ecosystem can be useful for services that must run reliably at scale.

Android applications: Java remains supported for Android development and many existing Android codebases use it. Kotlin is also fully supported and is commonly recommended for new Android work; Android development uses Android-specific APIs and build tools, not just a desktop JDK.

Desktop software, business systems and automation: Java can power a graphical desktop app, a company’s transaction processing system or a command-line tool that checks files and produces reports. The libraries and deployment approach differ by application. Large financial and business systems often value stable tooling and maintainable code, while a small script may be quicker to write in another language.

Java beside Python and C#

Python often lets beginners express a short script with less setup and less punctuation; Java catches many type mistakes during compilation and has a different deployment model. C# shares several ideas with Java, including static typing and class-based programming, but C# commonly targets the .NET runtime and uses its own libraries and tools. Neither language is universally faster, simpler or better; consider the project, platform and team.

LanguageTypical starting pointRuns with
JavaA .java file compiled to bytecodeA compatible JVM
PythonA .py scriptA Python implementation
C#A .cs source file in a .NET projectA suitable .NET runtime or compiled native application

Advantages and limitations

Java’s strengths include early type checking, mature libraries, portable bytecode and widely used tools for testing and maintenance. Garbage collection manages much routine memory reclamation, and the standard library supplies collections, files, networking and more. These benefits matter in long-lived applications maintained by a team.

Java can also require more setup and more explicit structure than a short script in some languages. The JVM and application dependencies add deployment considerations; memory use and startup time matter for some workloads. Compiler checks cannot prove a program is correct, and Java does not automatically validate untrusted input or protect a service. Profile and test a real application before making performance or security claims.

Read your first Java program

The example below defines a class named Main. Its main method is an entry point that the Java launcher can call. System.out.println writes the quoted text to standard output and then starts a new line. Save the text as Main.java; the public class name and filename must match. After installing a JDK, run javac Main.java to create Main.class, then java Main to execute the class. The expected output is Hello, Codectionary!.

Change the text inside the quotation marks, compile again and run again. Recompiling matters: java Main runs the previously generated class file until javac produces a new one. Newer Java releases also have simpler source-launching options, but this explicit two-step path shows what the compiler and runtime each do.

Main.java

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Codectionary!");
    }
}

Terminal — compile and run

javac Main.java
java Main

Choose your next step

First learn how source, bytecode and the JVM fit together. Then choose your operating system’s JDK guide and either use a plain editor or set up VS Code or IntelliJ IDEA. Run the first program locally, change it and observe the result. Continue with variables, conditions, methods, classes and collections; build a small command-line project before moving to a framework.

Syntax

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Codectionary!");
    }
}

Examples

A first Java program

Save as Main.java, compile with javac Main.java and run with java Main.

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Codectionary!");
    }
}
  1. public class Main names a class that contains the program; because it is public, the file is Main.java.
  2. public static void main(String[] args) is the conventional entry point for this class-based example.
  3. System.out.println prints Hello, Codectionary! followed by a newline. The semicolon ends the statement.
  4. javac checks and compiles the source; java Main launches the resulting class. A source edit requires recompilation.

Java: background & uses

Used for
Backend services, Enterprise software, JVM applications
Created by
James Gosling and the team at Sun Microsystems
First released
1995 · public debut
Version / standard
Java 27

Feature release as of October 2026; Java 25 is the latest LTS release. Check the current roadmap before installing.

In the real world

  • Netflix: DGS, its GraphQL services framework
  • LinkedIn: Online services for its AI platform
  • Spotify: The Java API for Voyager vector search

Facts checked 8 September 2026. Product links describe documented uses.

Best practices

  • Install a JDK rather than only a runtime when you want to compile Java.
  • Keep the class name and source filename aligned in a public-class example.
  • Check the JDK version required by an existing project before changing it.

Runtime & versions

Java Virtual Machine. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Java Language Specification

Specifications & further reading