Java Tutorial · Java Basics · Lesson 1 of 37

Java Introduction

What Java is, where it's used and how Java programs run.

What is Java?

Java is a popular, object-oriented, statically typed programming language created at Sun Microsystems in 1995 (now owned by Oracle). Its promise is "write once, run anywhere": Java code compiles to bytecode that runs on the Java Virtual Machine (JVM) on any operating system.

Java powers:

  • Back-end services — Spring Boot is one of the most used server frameworks in the world.
  • Android apps (alongside Kotlin).
  • Big data tools like Kafka, Hadoop and Elasticsearch.
  • Banking, insurance and other large enterprise systems.

Your first Java program

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

Output

Hello, World!

Run this on your computer — see “Get Started” for setup.

Every Java program needs a class (here Main) and a main method — the entry point the JVM calls. System.out.println() prints a line.

Running Java examples

Java needs a compiler, so Java examples on this site show the program and its output. Copy any example into a file named Main.java and run it with java Main.java (see Get Started). This tutorial uses Java 21, the current long-term-support (LTS) release.

Test yourself

What runs compiled Java bytecode?

  1. The browser
  2. The JVM
  3. The Java compiler
  4. The operating system directly
Show answer

Answer: The JVM