Java: Getting Started
⏱ 15 min read
Java is one of the world's most widely-used programming languages. It powers Android apps, enterprise software, and billions of devices.
How Java Works:
Java uses a special two-step process:
1. You write code in a .java file
2. The Java compiler (javac) turns it into bytecode (.class file)
3. The Java Virtual Machine (JVM) runs that bytecode on any computer
This is why Java is called "Write Once, Run Anywhere" — the same bytecode works on Windows, Mac, and Linux.
Breaking Down Hello World:
public class HelloWorld — creates a class named HelloWorld. Every Java program lives inside a class. The filename MUST match the class name exactly.
public static void main(String[] args) — the main method. Java always starts executing from here. Think of it as the "front door" of your program.
System.out.println(...) — prints text to the console and adds a new line.
System.out.print() — prints without a new line.
Comments in Java:
// This is a single-line comment
/* This is a multi-line comment */
Java ignores all comments — they are notes for humans only.
How to Run Java:
1. Install the JDK (Java Development Kit) from java.com
2. Save your file as HelloWorld.java
3. Open a terminal and run: javac HelloWorld.java
4. Then run: java HelloWorld
How Java Works:
Java uses a special two-step process:
1. You write code in a .java file
2. The Java compiler (javac) turns it into bytecode (.class file)
3. The Java Virtual Machine (JVM) runs that bytecode on any computer
This is why Java is called "Write Once, Run Anywhere" — the same bytecode works on Windows, Mac, and Linux.
Breaking Down Hello World:
public class HelloWorld — creates a class named HelloWorld. Every Java program lives inside a class. The filename MUST match the class name exactly.
public static void main(String[] args) — the main method. Java always starts executing from here. Think of it as the "front door" of your program.
System.out.println(...) — prints text to the console and adds a new line.
System.out.print() — prints without a new line.
Comments in Java:
// This is a single-line comment
/* This is a multi-line comment */
Java ignores all comments — they are notes for humans only.
How to Run Java:
1. Install the JDK (Java Development Kit) from java.com
2. Save your file as HelloWorld.java
3. Open a terminal and run: javac HelloWorld.java
4. Then run: java HelloWorld
Log in to track your progress and earn badges as you complete lessons.
Log In to Track Progress