Java ยท Chapter 2 of 42
Java JDK Install & Setup
To write and run Java programs you need the JDK (Java Development Kit), which includes the compiler (javac), the runtime (JRE), and other tools.
You can download the JDK from Oracle or use an open-source distribution like OpenJDK, Adoptium (Temurin), or Amazon Corretto.
Syntax
javac Main.java
java MainInstalling the JDK
Download JDK from adoptium.net or oracle.com, install it, then set the JAVA_HOME environment variable and add it to your PATH.
Editors and IDEs
IntelliJ IDEA and Eclipse are popular full Java IDEs. VS Code with the Java Extension Pack is a lighter alternative.
Example 1 (bash)
java -versionOutput
java version "21.0.1"Checks that Java is installed and shows its version.
Example 2 (bash)
javac Main.java
java MainOutput
Hello, World!Compiles Main.java into Main.class bytecode, then runs it on the JVM.
Key points
- The JDK includes the compiler, runtime and tools.
- javac compiles .java files into .class bytecode files.
- java runs compiled bytecode on the JVM.
- IntelliJ IDEA and Eclipse are popular Java IDEs.
๐ก Note: JDK 17 and 21 are current Long-Term Support (LTS) versions widely used in industry.
