๐Ÿงฐ Java Basics to Intermediate
Estimated reading: 3 minutes 118 views

๐Ÿš€ Java Get Started โ€“ How to Install, Setup & Run Your First Java Program


๐Ÿงฒ Introduction โ€“ Get Up and Running with Java in Minutes

Youโ€™ve learned what Java is. Now itโ€™s time to write and run your first Java program! This guide walks you through the entire Java setup process โ€” from downloading the JDK to compiling and executing your first program.

Whether you’re on Windows, macOS, or Linux, this step-by-step tutorial ensures youโ€™ll be ready to start coding in Java โ€” no prior experience needed!

By the end of this guide, you’ll be able to:

  • โœ… Download and install the Java JDK
  • โœ… Set up JAVA_HOME and PATH
  • โœ… Use a code editor or IDE to write Java code
  • โœ… Compile and run a basic Java program

๐Ÿ“ฅ Step 1: Download and Install Java JDK

Java programs are written using the Java Development Kit (JDK), which includes:

  • ๐Ÿงฑ Java Compiler (javac)
  • ๐Ÿงช Java Virtual Machine (JVM)
  • ๐Ÿ“ฆ Java Runtime Environment (JRE)
  • ๐Ÿ› ๏ธ Development tools and libraries

๐Ÿ”ง Where to Download:

โžก๏ธ Visit: https://www.oracle.com/java/technologies/javase-downloads.html

Alternative OpenJDK providers:

  • AdoptOpenJDK (Eclipse Temurin)
  • Amazon Corretto
  • Azul Zulu

๐Ÿ“˜ Tip: Choose the latest LTS version like Java 17 or Java 21 for best stability.


โš™๏ธ Step 2: Install and Configure Environment Variables

After installation, you need to configure JAVA_HOME and update your systemโ€™s PATH.

๐Ÿ–ฅ๏ธ For Windows:

  1. Search โ€œEnvironment Variablesโ€
  2. Add JAVA_HOME โ†’ Path to your JDK folder (C:\Program Files\Java\jdk-XX)
  3. Edit PATH โ†’ Add %JAVA_HOME%\bin

๐Ÿ’ป For macOS/Linux:

Add this to your terminal profile (.bashrc, .zshrc, or .bash_profile):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-XX.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

โœ… Check Installation:

java -version
javac -version

Expected output:

java version "21.0.1"
javac 21.0.1

๐Ÿ“ Step 3: Write Your First Java Program

You can use any editor like:

  • Visual Studio Code
  • IntelliJ IDEA
  • Eclipse
  • Even Notepad or terminal editors

๐Ÿ“„ Create a File: HelloWorld.java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Welcome to Java!");
    }
}

โœ… Line-by-Line Explanation:

  • public class HelloWorld โ€” Defines the class
  • public static void main โ€” Entry point of execution
  • System.out.println(...) โ€” Outputs text to console

๐Ÿƒ Step 4: Compile and Run Java Code

๐Ÿ”จ Compile:

javac HelloWorld.java

This creates a HelloWorld.class file (bytecode).

โ–ถ๏ธ Run:

java HelloWorld

๐Ÿ–จ๏ธ Output:

Welcome to Java!

๐ŸŽ‰ Congratulations! You’ve just run your first Java program.


๐Ÿงฐ Optional: Set Up Java in an IDE

Using an IDE simplifies development with syntax highlighting, auto-complete, and integrated terminal.

๐Ÿ† Recommended Java IDEs:

IDEFeatures
IntelliJ IDEASmart refactoring, built-in debugger, Gradle/Maven integration
EclipsePopular for enterprise Java, plugin-rich
VS CodeLightweight, Java extensions via Marketplace

๐Ÿ’ก Tip: Use IntelliJ IDEA Community Edition for a powerful, free experience.


โœ… Summary โ€“ Java Get Started

Hereโ€™s what youโ€™ve accomplished:

  • Installed Java JDK
  • Set environment variables (JAVA_HOME, PATH)
  • Wrote a Java program
  • Compiled and ran it from the terminal

Now you’re ready to explore Java’s syntax, control structures, and object-oriented features.


โ“FAQs โ€“ Java Get Started

โ“ What is the difference between JDK and JRE?

  • JDK (Java Development Kit): For writing and compiling Java apps
  • JRE (Java Runtime Environment): For running already compiled Java apps

โ“ Do I need to set JAVA_HOME?

Yes, itโ€™s required for many tools (like Maven, Gradle, IDEs) and scripts that depend on Java.

โ“ Can I install multiple Java versions?

Yes, use tools like jEnv (macOS/Linux) or SDKMAN to manage them.

โ“ Which Java version should I use in 2025?

Java 17 or Java 21 (both LTS versions) are recommended for stability and long-term support.


Share Now :
Share

Java Get Started

Or Copy Link

CONTENTS
Scroll to Top