C
Java/Setup/Lesson 02

Java Environment Setup — From IntelliJ to Hello World

30 min·theory

Java Environment Setup — From IntelliJ to Hello World

🎯 What you'll be able to do after this lesson

After completing this lesson, you'll be confident doing all three of the following.

  • ✅ Complete environment setup from JDK 17 LTS to IntelliJ Community
  • ✅ Answer in one sentence when to choose Maven vs Gradle
  • ✅ Explain what .class / .jar files are and how they connect to the JVM

Keep these goals as a checklist — close the lesson once you can answer all of them.

Installing the JDK — Based on Java 17 LTS

Three things you need to run Java

  • JDK (Java Development Kit) — The full development package: compiler (javac) + runtime (java) + standard library.
  • JRE (Java Runtime Environment) — For running programs only. Included inside the JDK.
  • JVM (Java Virtual Machine)The virtual machine that actually executes your code. Differs per operating system.

As a developer, you only need the JDK — the JRE and JVM are bundled inside it.

Which version to download

Java 17 LTS is the safest choice as of 2026. LTS = Long Term Support, 8 years of support. The #1 choice in production.

  • Java 8: Too old. Don't use it for new projects.
  • Java 11: The previous LTS. Declining in usage.
  • Java 17: The current standard. Minimum requirement for Spring Boot 3.x.
  • Java 21: The latest LTS. Fine for brand-new projects; 17 is recommended for learning.

Installation — Adoptium Temurin

The official Oracle JDK has commercial licensing concerns and is rarely used in practice. Instead, download Adoptium Temurin, a free OpenJDK distribution.

1. Go to https://adoptium.net
2. Select Temurin 17 (LTS) → choose your OS (Windows/Mac/Linux)
3. Download the .msi (Windows) or .pkg (Mac) → run the installer
4. Proceed through the setup wizard with default options (confirm the PATH auto-registration checkbox)

Verify the installation

Open a terminal/CMD and run:

bash
java -version
javac -version

If both show 17.x.x, you're good. If javac is not found, you only installed the JRE — download the JDK instead.

Installing IntelliJ IDEA — The Free Community Edition

Why IntelliJ

The de facto standard IDE in the Java ecosystem, with an overwhelming #1 adoption rate in professional settings. The free Community edition is sufficient (Spring and web development require the paid Ultimate edition, but it's free for students and open source).

  • Eclipse: Was once the standard, but market share has declined. Heavyweight with an outdated UX.
  • VS Code + Java extensions: Lightweight, but lacks the integrated tooling of IntelliJ. Good for light work.
  • NetBeans: Rarely used.

Download

1. Go to https://www.jetbrains.com/idea/download/
2. Click Download under Community Edition (it appears in small text next to Ultimate)
3. Run the setup wizard — check Add Open Folder as Project

Creating your first project

After launching, select New Project and choose the following options:

  • Language: Java
  • Build system: IntelliJ (for learning — Maven/Gradle will be covered in the next lesson)
  • JDK: Temurin 17 installed above will be auto-detected
  • Project name: hello-java
  • Add sample code checked — Main.java will be generated automatically

Click Create to open the project.

Running for the first time

You should see the auto-generated src/Main.java:

java
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello and welcome!");
    }
}

Click the green ▶ arrow in the left gutter of the editor, or press Shift + F10Hello and welcome! will appear in the Run panel at the bottom.

Congratulations — you just ran your first Java program.

Maven vs Gradle — Summarized in One Line

Why you need a build tool

Real projects depend on hundreds of external libraries. Downloading them by hand, dropping them in a folder, and registering them on the classpath is madness. A build tool automates all of that.

A build tool does four things:
1. Dependency management — automatically downloads and version-manages libraries
2. Compilation — invokes javac with unified options
3. Test execution — automatically runs JUnit and other test frameworks
4. Packaging — bundles everything into a .jar or .war

Two options

  • Maven — Configured via XML (pom.xml). Introduced in 2004. The traditional standard. Common in large enterprises and legacy projects. Follows the "Convention over Configuration" principle.
  • Gradle — Configured via Groovy/Kotlin DSL (build.gradle.kts). The default for new Spring Boot projects. Faster and more flexible. The standard for Android.

One-line conclusion: Use Gradle for learning Spring Boot; use Maven if the existing company codebase uses Maven. Knowing both is a plus, but choose Gradle for new projects.

Maven pom.xml example

xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>3.2.0</version>
</dependency>

Gradle build.gradle.kts example

kotlin
dependencies {
    implementation("org.springframework.boot:spring-boot-starter-web:3.2.0")
}

Gradle expresses the same dependency much more concisely — which is why preference for Gradle grows as projects get larger.

.class · .jar Files — What compiled output really is

Source → Bytecode → Execution

To understand what build output is, you need to grasp Java's two-stage execution model.

1. .java (source) — the text code you write
2. .class (bytecode) — compiled by javac into a format the JVM can read
3. The JVM executes the .class file — translating it into native machine code on the fly for the current OS

code
[Human]     [Compiler]    [Runtime]
Main.java → Main.class → JVM (java Main)

Inside a .class file

It's binary, not text. You can't read it directly, but you can disassemble it with javap -c Main.class.

One file = one class. If Main.java contains class A and class B, you'll get A.class and B.classtwo files.

.jar — Java Archive

A ZIP-format file that bundles dozens or hundreds of .class files into a single unit for distribution and execution.

bash
java -jar myapp.jar

This single line loads hundreds of .class files and libraries to start the program.

Summary

ExtensionWhat it isWho creates it
.javaSource codeYou (the developer)
.classBytecode (for the JVM)javac compiler
.jarBundle of classes (for distribution)jar tool or build tool
.warWeb app bundle (.jar + web config)Build tool

In the next chapter, we'll start the main learning track with variables and data types.

🤖 Try asking AI like this

Once you know the concepts in this lesson, you can give AI precise instructions. Not a vague "fix this" — but a request with vocabulary — and that's where token savings begin.

  • "Create a Hello World project using Java 17 + IntelliJ Community"
  • "Convert this project's Maven pom.xml to a Gradle build.gradle.kts"
  • "JAVA_HOME isn't being recognized — show me how to set it on each OS"

Why this saves tokens

Without the concepts, even after receiving an AI response you'll need to follow up with "What does that mean?" — and those follow-ups consume tokens. Learn the concept once, and the conversation ends in one exchange.

Java Environment Setup — From IntelliJ to Hello World - Java