← Chapter 1 — Getting Started with Java

1. Java Introduction & History

mixed

Description

Java is a general-purpose programming language used for web services, Android apps, desktop tools, and large business systems. It was designed so that the same program can run on many operating systems.

Java code is written in files, compiled into bytecode, and then run by the Java Virtual Machine. This workflow helps beginners focus on the program rather than the computer they use.

Subtopics

Why Java?

Description

Java is readable and widely used.

Explanation

Its large ecosystem and stable tooling make it a practical first language.

Example

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

Compiled language

Description

Java source is transformed before it runs.

Explanation

The compiler checks many mistakes early and produces bytecode.

Example

javac HelloJava.java

Explanation

The Java slogan "write once, run anywhere" refers to bytecode being portable across JVM implementations. You still need to write clear code and test it on the environments your users will use.

Example

Save this as HelloJava.java, compile it with javac, then run java HelloJava.

public class HelloJava {
    public static void main(String[] args) {
        System.out.println("Welcome, Aditi!");
    }
}

Output

Welcome, Aditi!

Key points

  • Java is platform independent through the JVM.
  • Source code is compiled before it runs.
  • Every program begins with a class.