Getting Started Lesson 2 of 21
Getting Started with Java — Install the JDK and Run a Program
Install the Java Development Kit, write a program in a text editor, compile it with javac, run it with java, and choose an IDE such as VS Code, NetBeans or IntelliJ.
To write Java programs, you need the JDK (Java Development Kit). It includes the compiler (javac), the JVM (java) and Java's built-in libraries. Here's how to set everything up.
Step 1: Install the JDK
- Download a free JDK, such as Eclipse Temurin (adoptium.net) or Oracle JDK (oracle.com/java). Choose the latest LTS version (Long-Term Support) for your operating system.
- Run the installer. On Windows, if you see an option to "Set JAVA_HOME" or "Add to PATH", turn it on.
Step 2: Check the installation
Open Command Prompt (Windows) or Terminal (Mac/Linux) and type:
java -version
javac -version
Output
openjdk version "21.0.5" 2024-10-15 LTS javac 21.0.5
Any version 17 or higher is perfect for this course. If you see "not recognized", the JDK isn't on your PATH: reinstall and turn on the PATH option, or restart your computer.
Step 3: Write your program
Open any text editor (even Notepad) and type:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello from Java!");
System.out.println("Grade 11 - TVL ICT");
}
}
Save it as Hello.java in a folder such as Documents\java.
Step 4: Compile and run
cd Documents\java
javac Hello.java
java Hello
Output
Hello from Java! Grade 11 - TVL ICT
javac Hello.javacompiles your code. If there are no errors, it createsHello.classsilently.java Helloruns the program. Notice: no.classor.javaat the end.
Since Java 11, you can also run a single file directly with java Hello.java, which compiles and runs in one step.
Using an IDE
An IDE (Integrated Development Environment) combines an editor, compiler and runner, with helpful features like auto-complete and error highlighting.
| IDE | Good for |
|---|---|
| VS Code + "Extension Pack for Java" | Light and fast, works for many languages |
| Apache NetBeans | Common in Philippine schools; easy GUI (Swing) designer |
| IntelliJ IDEA Community | Professional, smart suggestions |
| BlueJ | Made for beginners learning classes and objects |
In an IDE, you usually just press a green ▶ Run button.
Compile errors
If you make a mistake, javac refuses to compile and tells you where:
public class Hello {
public static void main(String[] args) {
System.out.println("Hello")
}
}
Error
Hello.java:3: error: ';' expected
System.out.println("Hello")
^
1 errorThe message gives the file, line number (3) and what's missing. The ^ points to the exact spot. Fix it, save, and compile again.
No computer?
Online Java compilers let you write and run Java in a browser, on any phone or tablet. Most of them require the class to be named Main, so the examples in this course use public class Main.
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04