Getting started with Java
Install the JDK, write a class and run it.
Java code compiles to bytecode that runs on the Java Virtual Machine, so the same program runs on Windows, Linux or Mac. It is common in banking and enterprise software, and in placement tests.
Set up
- Install a current JDK (version 17 or 21).
- Save your code as Main.java. The file name must match the public class name.
- Compile with javac Main.java, then run it with java Main.
Java
public class Main {
public static void main(String[] args) {
System.out.println("Vanakkam, Java!");
System.out.println(2 + 3);
}
}Output
Vanakkam, Java! 5
Every program starts at main. Statements end with a semicolon, and braces group code. Java is case sensitive, so String and string are different.