Skip to lesson

Java is a programming language: a way to write instructions that a computer can follow. People use it to build phone apps, websites and the servers behind them.

What is a programming language?

A computer only follows exact instructions. A programming language is a set of words and rules for writing them, and the instructions are called code. This is one line of Java code:

Java
System.out.println("Hello, World!");

It tells the computer to show Hello, World! on the screen. Code that does a whole job, like a calculator app, is called a program.

Java is one programming language. It came out in 1995, and millions of people use it today. Its rules are clear and strict, so it is a good first language.

Where is Java used?

You probably use Java software every day without seeing it. Much of it runs on a server: a computer that runs all the time and answers requests from apps. Not every such app uses Java, but many do.

  • Android apps – Java is one of the main languages for Android apps.
  • Banking and payments – many banks and payment systems use Java on their servers.
  • Websites – many shopping, booking and ticket sites use Java on their servers.
  • Jobs – Java is one of the skills software companies ask for most, from start-ups to large firms.

How does Java run?

Your .java file is text, and the computer cannot run it directly. So Java works in two steps: the compiler turns your code into bytecode (simple instructions for Java), and the JVM (Java Virtual Machine) runs that bytecode.

  1. You write the code: Hello.java
  2. The compiler turns it into bytecode: Hello.class
  3. The JVM runs the bytecode on your computer
Hello.java is compiled by javac into Hello.class, the bytecode. The JVM runs that same file on Windows, macOS or Linux.

There is a JVM for Windows, macOS and Linux, so the same Hello.class runs on all of them. This is called "write once, run anywhere".

You will also see the names JDK, JRE and JVM often. The next lesson (opens in a new tab) explains them simply.

Example

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

What this code does

  • A preview of a small Java program. System.out.println prints the text inside the double quotes.
  • In this course, we will initially use the traditional Java program structure, where execution begins in public static void main(String[] args). Newer Java versions also support simpler forms, which we can explore later.
  • No need to type it now. You will write and run it yourself in the lesson Your first Java program.

Next step

Check your understanding

5 quick questions