What is Java?
10 min · Beginner
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 can only follow instructions. A programming language is a set of words and rules we use to write these instructions.
The instructions we write are called code. Code that does a job is called a program. A calculator app is 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 many teachers recommend it as a first language.
Where is Java used?
You probably use software made with Java often. Some of it runs on a server. A server is a computer that runs all the time and answers requests from apps.
These are common uses of Java. 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 – companies like TCS, Infosys and Wipro hire many Java developers.
How does Java run?
You write Java code in a file that ends with .java. The computer cannot run this file directly. So Java uses two steps.
First, a tool called the compiler turns your code into bytecode. Bytecode is an intermediate instruction format that a compatible JVM can execute. Then the JVM (Java Virtual Machine) runs the bytecode.
JVM implementations exist for different platforms, such as Windows, macOS and Linux. So the same bytecode can run on all of them. This is called "write once, run anywhere".
- You write the code:
Hello.java - The compiler turns it into bytecode:
Hello.class - The JVM runs the bytecode on your computer
Example
public class Hello { public static void main(String[] args) { System.out.println("Hello, World!"); }}Hello, World!
What this code does
- A preview of a small Java program.
System.out.printlnprints 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