Skip to content

Latest commit

 

History

History
37 lines (25 loc) · 1.14 KB

File metadata and controls

37 lines (25 loc) · 1.14 KB

Setup Java Locally

A quick guide to installing Java, setting up your environment, and running Java programs.

Install JDK

  1. Download the Java Development Kit (JDK) from Oracle Java Downloads.
  2. Follow the installation instructions for your operating system.

Set JAVA Environment Variable

Setting up the JAVA_HOME environment variable is essential for compiling and running Java programs.

After setup, verify installation by running:

java -version
javac -version

Running Java Code

  • Using VS Code

    • Install the Java Extension Pack (by Microsoft) from the Extensions tab.
    • Open your .java file.
    • Click "Run" or use shortcut Ctrl + F5 to 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.