Starting a Java Program
1. Steps for Absolute Beginners
- Install JDK 17/21, check
java -version. - Write
Hello.javain Notepad/VS Code. - Compile:
javac Hello.java→ makesHello.class. - Run:
java Hello(no.classin command!).
2. First Program (typed, not copied)
public class Hello {
public static void main(String[] args) {
System.out.println("I am running Java!");
}
}
3. What Happens Behind
Hello.java (you type) → javac (compiler) → Hello.class (bytecode) → java (JVM) → output
Error? javac: file not found → wrong folder (use cd). Main method not found → spelling of main / String[] args wrong.
4. IDE Shortcut (after command line once)
IntelliJ/Eclipse: New Project → New Class → Run button does javac+java for you. Learn command line first for exams.
5. Exam Points
- Steps javac/java with commands — 5 marks, very frequent.
- First program + output — 3 marks, frequent.
- Common errors (filename, main spelling) — 2-3 marks.