☕ Java
Java Environment Setup
Installing the JDK is just the first step. A complete Java development environment includes a configured IDE, a build tool, version management, and the right JVM settings for your workflow. Here's how to set up a professional Java environment from scratch.
The Complete Java Toolchain
A professional Java environment has five components working together:
- JDK — The compiler and runtime. The foundation everything else needs.
- JAVA_HOME — Environment variable pointing to the JDK. Required by build tools.
- IDE — IntelliJ IDEA or VS Code. Where you write and debug code.
- Build Tool — Maven or Gradle. Manages dependencies, compilation, and packaging.
- Version Manager (optional but recommended) — SDKMAN for switching between Java versions.
You can write Java with just the JDK and a text editor. But adding the other pieces is what takes you from running experiments to building real software.
Step 1 — Install the JDK
Install Java 21 (current LTS). Eclipse Temurin is the recommended open-source distribution — it's what most enterprises use.
Shell
# macOS (Homebrew):
brew install --cask temurin@21
# Ubuntu/Debian:
sudo apt update && sudo apt install openjdk-21-jdk
# Windows — download installer from: adoptium.net
# Verify:
java -version && javac -versionStep 2 — Configure JAVA_HOME
Build tools read JAVA_HOME to find the JDK. Set it in your shell profile so it persists across sessions.
Shell
# macOS (add to ~/.zshrc):
export JAVA_HOME=$(/usr/libexec/java_home -v 21)
export PATH=$JAVA_HOME/bin:$PATH
# Linux (add to ~/.bashrc):
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
# Reload:
source ~/.zshrc # or source ~/.bashrc
# Verify:
echo $JAVA_HOMEStep 3 — Choose and Configure an IDE
IntelliJ IDEA is the industry standard for Java. The free Community Edition covers everything you need — commercial frameworks like Spring are supported through plugins.
After installing IntelliJ:
1. Open Preferences → Build, Execution, Deployment → Build Tools → Maven/Gradle
2. Set the JDK: File → Project Structure → SDK → add your JDK path
3. Install plugins: Lombok (if using Lombok), SonarLint (code quality), GitToolBox
VS Code is a good lightweight alternative. Install the "Extension Pack for Java" by Microsoft — it adds IntelliSense, debugging, Maven/Gradle support, and test running.
Step 4 — Install a Build Tool
Maven and Gradle are the two dominant Java build tools. Both manage dependencies, compile your code, run tests, and package your application. Gradle is faster; Maven is more established in enterprise environments.
Shell
# Install Maven (macOS):
brew install maven
mvn -version
# Install Gradle (macOS):
brew install gradle
gradle -version
# Install Maven (Ubuntu):
sudo apt install maven
# Create a new Maven project from the command line:
mvn archetype:generate -DgroupId=com.example -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
# Create a new Gradle project:
mkdir my-app && cd my-app
gradle init --type java-applicationStep 5 — SDKMAN for Version Management
If you work on multiple Java projects, they may require different Java versions. SDKMAN makes switching between versions a single command — and it manages Maven, Gradle, and other JVM tools too.
Shell
# Install SDKMAN (macOS/Linux):
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
# Install Java versions:
sdk install java 21-tem # Eclipse Temurin 21
sdk install java 17-tem # Eclipse Temurin 17
sdk install java 21-graalce # GraalVM Community 21
# Switch versions:
sdk use java 17-tem # switch for current session
sdk default java 21-tem # set permanent default
# Install build tools via SDKMAN:
sdk install maven
sdk install gradle
# List all available Java versions:
sdk list javaVerifying the Full Setup
Run through this checklist to confirm everything is wired correctly:
Shell
# 1. JDK installed and on PATH:
java -version
javac -version
# 2. JAVA_HOME set correctly:
echo $JAVA_HOME
ls $JAVA_HOME/bin/javac # should exist
# 3. Build tool working:
mvn -version # or: gradle -version
# 4. Create and run a test project end-to-end:
mkdir TestProject && cd TestProject
cat > Main.java << 'EOF'
public class Main {
public static void main(String[] args) {
System.out.println("Environment works!");
}
}
EOF
javac Main.java && java Main
# Output: Environment works!Related Topics in Introduction
What is Java?
Java is a high-level, object-oriented programming language built on one killer idea: write your code once, and run it on any device — Windows, Mac, Linux, phone, smartwatch, you name it. No rewrites needed.
Features of Java
Java didn't become one of the world's most used languages by accident. From running on any device to handling millions of users simultaneously, here's what makes Java genuinely powerful — and why companies keep betting on it.
Uses of Java
Java powers everything from Android apps to banking systems, from Netflix's backend to NASA's mission control. Here's where Java is actually used in the real world — and why it keeps showing up in the most critical systems on the planet.
Java Editions (Java SE, EE, ME)
Java isn't one-size-fits-all. It comes in three distinct editions — each built for a different environment. Whether you're building a desktop app, a banking backend, or firmware for a SIM card, there's a Java edition designed exactly for that job.