A quick guide to installing Java, setting up your environment, and running Java programs.
- Download the Java Development Kit (JDK) from Oracle Java Downloads.
- Follow the installation instructions for your operating system.
Setting up the JAVA_HOME environment variable is essential for compiling and running Java programs.
- Follow this guide: Setting Environment in Java
After setup, verify installation by running:
java -version
javac -version-
Using VS Code
- Install the Java Extension Pack (by Microsoft) from the Extensions tab.
- Open your
.javafile. - Click "Run" or use shortcut
Ctrl+F5to execute.
-
Using Command Line
javac Main.java # Compile java Main # Run
Important
Important: The filename must match the public class name. For example, if your class is public class Main, save the file as Main.java. Java is case-sensitive.