Setting Up Your Environment — JDK and IntelliJ IDEA

9 min read

To write Java you need two things: a JDK (Java Development Kit) and an IDE (Integrated Development Environment). The JDK gives you the compiler and runtime; the IDE gives you a code editor that knows Java intimately — autocompletion, error highlighting, refactoring, and a built-in terminal. The combination most enterprise QA teams use is Eclipse Temurin (the JDK) and IntelliJ IDEA Community (the IDE), and both are free. This lesson walks you through installing them, verifying the install, and compiling your first Java file from the command line so you understand what the IDE is doing under the hood.

JDK vs JRE — get this right once

You will see two acronyms thrown around. They are not the same:

  • JRE (Java Runtime Environment) — just enough to run compiled .class files. Browsers used to ship a JRE; it has no compiler.
  • JDK (Java Development Kit) — JRE + the compiler (javac) + tools (jar, javadoc, jshell, etc.). This is what you need to write Java.

Always install the JDK. If a teammate says "I have Java installed" and javac --version prints nothing, they have only the JRE.

Choosing a JDK distribution

The Java spec is open. Several organisations ship their own builds of it:

  • Eclipse Temurin (formerly AdoptOpenJDK) — the community-recommended free build. Get it from adoptium.net.
  • Oracle JDK — Oracle's official build. Free for development; commercial licence for some production uses.
  • Amazon Corretto, Azul Zulu, Microsoft Build of OpenJDK — equivalent free builds maintained by big tech companies.

For this course, install Eclipse Temurin unless your employer mandates a specific distribution. Pick a Long Term Support (LTS) version — at the time of writing that means JDK 17 or JDK 21. LTS versions are supported for years; non-LTS releases (18, 19, 20, 22…) are short-lived and should be avoided unless you have a reason.

Installing the JDK

  1. Visit adoptium.net and click "Latest LTS Release."
  2. Choose your OS (Windows / macOS / Linux) and architecture (x64 for most machines, aarch64 for Apple Silicon Macs).
  3. Run the installer. On Windows, accept the default option to "Set JAVA_HOME variable" and "Add to PATH." On macOS, the .pkg installer handles paths automatically.
  4. Open a terminal — Terminal on macOS/Linux, PowerShell or Command Prompt on Windows.
  5. Verify the install:
java -version
javac -version

You should see something like:

openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode)
javac 21.0.2

If java -version works but javac -version says "command not found," the JRE is on the PATH but the JDK isn't. Re-run the installer with the "Set PATH" option ticked.

JAVA_HOME — the one environment variable that matters

Most build tools (Maven, Gradle, IntelliJ) look for an environment variable called JAVA_HOME that points at the JDK install directory. The Temurin Windows installer sets this for you; on macOS and Linux you sometimes need to do it manually.

Windows — System Properties → Environment Variables → New:

Name:  JAVA_HOME
Value: C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot

Then in the Path variable, add %JAVA_HOME%\bin.

macOS / Linux — add to ~/.zshrc (macOS default) or ~/.bashrc:

export JAVA_HOME=$(/usr/libexec/java_home)   # macOS — finds the JDK automatically
export PATH=$JAVA_HOME/bin:$PATH

On Linux, replace the first line with the actual path, e.g. export JAVA_HOME=/usr/lib/jvm/temurin-21-jdk-amd64. Reload your shell (source ~/.zshrc) and check echo $JAVA_HOME prints the right path.

Installing IntelliJ IDEA

JetBrains ships two editions:

  • Community — free, open-source, has everything you need for plain Java, Maven, Gradle, JUnit, TestNG, and Selenium. Use this one.
  • Ultimate — paid, adds enterprise frameworks (Spring, JavaScript debugging, database tools). Worth it eventually but not required for this course.

Download Community Edition for your OS and run the installer. Launch it, accept the licence, skip the "import settings" step on first launch.

An alternative is VS Code with the Java Extension Pack. It's lighter weight but the Java tooling is less polished — most enterprise QA teams use IntelliJ. We'll assume IntelliJ for the rest of this course.

Creating your first project

Launch IntelliJ → New Project → fill in:

  • Name: java-for-qa
  • Location: anywhere — your home directory is fine
  • Language: Java
  • Build system: IntelliJ (we'll switch to Maven later in chapter 7)
  • JDK: select the Temurin JDK you just installed (IntelliJ usually finds it automatically)
  • Add sample code: tick this so you get a starter Main.java

Click Create. IntelliJ generates this structure:

java-for-qa/
├── .idea/
├── src/
│   └── Main.java
└── java-for-qa.iml

Open Main.java. It already contains a public class Main with a main method. Click the green ▶ arrow next to the class name and pick "Run 'Main.main()'" — you'll see the output appear in a panel at the bottom. Congratulations, you've run your first Java program.

The setup, end to end

Step 1 of 6

Install the JDK

Download Temurin LTS (JDK 21) from adoptium.net. Tick 'Set JAVA_HOME' and 'Add to PATH' on Windows.

What IntelliJ is doing for you — the terminal version

The IDE hides the compile-and-run cycle. Once, do it by hand so you understand what's happening.

mkdir java-for-qa-cli
cd java-for-qa-cli
cat > Main.java <<'EOF'
public class Main {
    public static void main(String[] args) {
        System.out.println("Environment ready!");
    }
}
EOF
javac Main.java        # compile — produces Main.class
java Main              # run — note: NO .class extension

Output:

Environment ready!

Two files exist now: Main.java (your source) and Main.class (the compiled bytecode). The JVM runs the .class file. Every time you change the source, you must re-run javac. IntelliJ does both steps automatically when you click the green ▶, but knowing what's underneath is invaluable when builds break in CI.

⚠️ Common mistakes

  • Installing the JRE only. java -version works but javac -version says "command not found." You need the JDK. Re-run the Temurin installer.
  • Mismatched IntelliJ JDK and command-line JDK. IntelliJ may use a JDK it bundled, while your terminal uses the system one. They can be different versions, leading to "works in IntelliJ, fails in CI." Confirm both java -version in your terminal and the Project Structure → SDKs panel in IntelliJ point at the same JDK.
  • Running java Main.class or java Main.java. Both are wrong on classic Java. Compile with javac Main.java, then run with java Main (the class name only — no extension). Java 11+ does have a single-file shortcut java Main.java, but learn the two-step flow first; it's what every build tool actually does.

🎯 Practice task

Get from zero to running Java code in about 25 minutes.

  1. Install the Temurin JDK 21 (or 17 if you prefer).

  2. Open a terminal and confirm java -version and javac -version both work.

  3. In a folder of your choice, create a file Hello.java containing:

    public class Hello {
        public static void main(String[] args) {
            System.out.println("Hello, QA!");
            System.out.println("Compiled with javac, run with java.");
        }
    }
  4. Compile and run from the terminal:

    javac Hello.java
    java Hello
  5. Confirm the output is two lines.

  6. Now do the same thing in IntelliJ: create a new project called java-for-qa, replace the generated Main.java body with the same System.out.println lines, and click ▶. Confirm the output appears in IntelliJ's run panel.

  7. Stretch: in IntelliJ, look at the bottom-right corner of the window — it shows the JDK version the project is using. Change it to a different version (Project Structure → Project SDK), click ▶ again, and watch IntelliJ recompile against the new JDK. This is the kind of switch you'll do for real when joining a project that's stuck on JDK 11 while your laptop has JDK 21.

You now have the tools real QA engineers use every day. Lesson 3 explains every word in the public static void main line so the program above stops looking like magic.

// tip to track lessons you complete and pick up where you left off across devices.