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
- 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)
- Select your operating system (Windows, macOS, Linux).
- Download the installer
.exe(Windows),.dmg(macOS), or package (.tar.gzfor Linux).
b) Install JDK
Windows:
- Run the downloaded
.exefile. - Follow the installation wizard and note the installation path (e.g.,
C:\\Program Files\\Java\\jdk-17). - Click Finish when installation is complete.
macOS:
- Open the
.dmgfile and drag JDK to the Applications folder. - 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:
- Open System Properties → Environment Variables
- Click New → JAVA_HOME → Path of JDK (e.g.,
C:\\Program Files\\Java\\jdk-17) - Add
%JAVA_HOME%\\binto 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
- Go to https://www.eclipse.org/downloads/
- Download Eclipse IDE for Java Developers.
- Extract and launch Eclipse.
- Set the workspace directory (where your projects will be stored).
- Create a new Java Project:
- File → New → Java Project → Enter Project Name → Finish
Option 2: IntelliJ IDEA
- Go to https://www.jetbrains.com/idea/download/
- Download Community Edition (Free).
- Install and launch IntelliJ IDEA.
- Click New Project → Java → Next → Finish
- 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
- Keep JDK updated – always use the latest stable version.
- IDE shortcuts – learn basic shortcuts to improve productivity.
- Workspace organization – keep your projects and libraries organized.
- Test run simple programs to ensure everything works before moving to advanced topics.
