C

Core Java tutorial for beginners

Clean • Professional

Setting Up Java Environment: JDK Installation & IDE Setup (Eclipse / IntelliJ)

3 minute

Setting Up Java Environment (JDK Installation & IDE Setup – Eclipse / IntelliJ)

Before writing your first Java program, you need a Java Development Environment set up on your computer. This includes the Java Development Kit (JDK) and an IDE (Integrated Development Environment) like Eclipse or IntelliJ IDEA.

This guide will show you step-by-step instructions for Windows, macOS, and Linux, making it easy for beginners to start coding.


Step 1: Install Java Development Kit (JDK)

The JDK contains everything you need to compile and run Java programs, including:

  • Java Compiler (javac)
  • Java Runtime Environment (JRE)
  • Libraries & Tools

a) Download JDK

  1. Go to the Oracle JDK download page:

https://www.oracle.com/java/technologies/javase-jdk17-downloads.html

(Alternatively, you can use OpenJDK if you prefer open-source)

  1. Select your operating system (Windows, macOS, Linux).
  2. Download the installer .exe (Windows), .dmg (macOS), or package (.tar.gz for Linux).

b) Install JDK

Windows:

  1. Run the downloaded .exe file.
  2. Follow the installation wizard and note the installation path (e.g., C:\\Program Files\\Java\\jdk-17).
  3. Click Finish when installation is complete.

macOS:

  1. Open the .dmg file and drag JDK to the Applications folder.
  2. Verify installation using Terminal:
java -version

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install openjdk-17-jdk
java -version

c) Set JAVA_HOME Environment Variable

Setting JAVA_HOME ensures that tools like IDE, Maven, and Gradle know where Java is installed.

Windows:

  1. Open System Properties → Environment Variables
  2. Click New → JAVA_HOME → Path of JDK (e.g., C:\\Program Files\\Java\\jdk-17)
  3. Add %JAVA_HOME%\\bin to the Path variable.

macOS/Linux (bash/zsh):

Add to ~/.bash_profile or ~/.zshrc:

export JAVA_HOME=/path/to/jdk-17
export PATH=$JAVA_HOME/bin:$PATH

Then run:

source ~/.bash_profile

d) Verify JDK Installation

Open Command Prompt/Terminal and run:

java -version
javac -version

Expected output should show Java 17 (or your installed version).


Step 2: Install an IDE (Eclipse / IntelliJ IDEA)

While you can use Notepad or VS Code, a full-fledged IDE makes coding easier with:

  • Code highlighting
  • Auto-completion
  • Debugging tools
  • Build and run support

Option 1: Eclipse IDE

  1. Go to https://www.eclipse.org/downloads/
  2. Download Eclipse IDE for Java Developers.
  3. Extract and launch Eclipse.
  4. Set the workspace directory (where your projects will be stored).
  5. Create a new Java Project:
    • File → New → Java Project → Enter Project Name → Finish

Option 2: IntelliJ IDEA

  1. Go to https://www.jetbrains.com/idea/download/
  2. Download Community Edition (Free).
  3. Install and launch IntelliJ IDEA.
  4. Click New Project → Java → Next → Finish
  5. Start writing your Java code with intelligent auto-completion and debugging features.

Step 3: Create Your First Java Program

Once your IDE is ready, create a simple Java program:

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

Run the program in your IDE:

  • Eclipse: Right-click → Run As → Java Application
  • IntelliJ: Click the green Run button

Output:

Hello, Java Environment!

Congratulations! Your Java development environment is now ready.


Tips for Beginners

  1. Keep JDK updated – always use the latest stable version.
  2. IDE shortcuts – learn basic shortcuts to improve productivity.
  3. Workspace organization – keep your projects and libraries organized.
  4. Test run simple programs to ensure everything works before moving to advanced topics.

Article 0 of 0