How to jdk version in intellij

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: In IntelliJ IDEA, you can set the JDK version for a project by navigating to File > Project Structure. Within Project Structure, select 'Project' on the left sidebar, then choose the desired JDK from the 'SDK' dropdown menu. If the desired JDK isn't listed, you can add it by clicking the '+' button and selecting 'Add SDK' > 'JDK'.

Key Facts

Overview

Managing the Java Development Kit (JDK) version used by your projects in IntelliJ IDEA is crucial for ensuring compatibility, leveraging new language features, and avoiding runtime issues. IntelliJ IDEA provides a flexible system for configuring the JDK at both the project level and the module level, allowing you to tailor the development environment precisely to your needs.

Why Managing JDK Versions Matters

Java versions introduce new features, performance improvements, and sometimes deprecate older functionalities. Using the correct JDK ensures:

Setting the JDK for a Project in IntelliJ IDEA

The primary way to manage your JDK is through the Project Structure settings. This allows you to define the SDK for the entire project or for individual modules within the project.

Step-by-Step Guide:

  1. Open Project Structure: Navigate to File > Project Structure... (or use the shortcut Ctrl+Alt+Shift+S on Windows/Linux, Cmd+; on macOS).
  2. Select 'Project': In the Project Structure dialog, select Project from the left-hand pane.
  3. Choose Project SDK: Under the 'Project' settings, you will see a dropdown menu labeled SDK. Click this dropdown.
  4. Select an Existing JDK: If the desired JDK is already configured in IntelliJ IDEA, it will appear in the list. Select it from the dropdown.
  5. Add a New JDK: If your desired JDK is not listed, click the Add SDK button (often represented by a '+' icon) and choose JDK. IntelliJ IDEA will then prompt you to locate the installation directory of the JDK on your system. Browse to the directory (e.g., `/usr/lib/jvm/java-17-openjdk-amd64` on Linux, `C:\Program Files\Java\jdk-17` on Windows, or `/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home` on macOS) and click 'OK'. IntelliJ IDEA will detect and add it to its list of available SDKs.
  6. Confirm Changes: Once you have selected or added the correct JDK, click Apply and then OK to close the Project Structure dialog.

Setting the JDK for a Module

Sometimes, you might have a multi-module project where different modules require different JDK versions. You can configure this within the same Project Structure dialog:

  1. Navigate to File > Project Structure...
  2. Select Modules from the left-hand pane.
  3. Choose the specific module you want to configure from the list.
  4. Under the Dependencies tab for that module, you can set the Module SDK. This setting overrides the project-level SDK for this particular module.
  5. As with the project SDK, you can select from existing JDKs or add new ones using the '+' button.

IntelliJ IDEA's JDK vs. Project JDK

It's important to distinguish between the JDK that IntelliJ IDEA itself uses to run (the IDE's JVM) and the JDK configured for your project. You can check and change the IDE's JDK in IntelliJ IDEA's settings (File > Settings > Build, Execution, Deployment > Build Tools > Gradle/Maven for build tools, or check the VM options for the IDE itself). However, for day-to-day development, the Project Structure settings are what you'll use most often to define the JDK for your code compilation and execution.

Common Issues and Troubleshooting

Best Practices

By correctly configuring your JDK in IntelliJ IDEA, you ensure a smooth and efficient development workflow, allowing you to focus on writing code rather than troubleshooting environment issues.

Sources

  1. SDKs: IntelliJ IDEA Helpfair-use
  2. JDK Projects - OpenJDKCC0-1.0
  3. Java SE Documentation | Oraclefair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.