Java is a general-purpose, statically-typed, object-oriented language. It runs on the JVM (Java Virtual Machine), which is why the same compiled program runs on Windows, Linux, macOS, and Android without change — "write once, run anywhere".
Where Java is used
- Android apps (alongside Kotlin, which also runs on the JVM)
- Enterprise backends — banking, insurance, government systems
- Big data — Hadoop, Spark, Kafka are all JVM software
- Desktop tools — anything built with Swing or JavaFX
In Nepal, Java is the backbone of most core banking software and a large share of BSc CSIT / BE Computer coursework.
Your first program
public class Main {
public static void main(String[] args) {
System.out.println("Namaste, Nepal!");
}
}Save it as Main.java — the file name must match the public class
name exactly. Then:
javac Main.java # compile → Main.class (bytecode)
java Main # run on the JVMSince Java 11 you can skip the separate compile step for single files:
java Main.javaReading that program
| Part | Meaning |
|---|---|
public class Main |
Everything in Java lives inside a class |
public static void main(String[] args) |
The entry point the JVM looks for |
static |
Belongs to the class, so no object is needed to run it |
void |
Returns nothing |
String[] args |
Command-line arguments |
System.out.println(...) |
Print a line to the console |
The main signature is fixed — change any part of it and the JVM will
not find your entry point.
JDK vs JRE vs JVM
- JVM runs bytecode.
- JRE = JVM + standard libraries (running only).
- JDK = JRE + compiler and tools (what you need to develop).
Install a JDK — version 17 or 21 (both long-term-support releases) is a good default.
Knowledge Check
4 questions — test your understanding
What is the difference between `==` and `.equals()` in Java?
What does `final` mean when applied to a variable?
What is an interface in Java?
What does `String` being immutable mean in Java?