How to jdk 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: To use a JDK in IntelliJ IDEA, you need to configure it within your project settings. You can either download a new JDK through IntelliJ or point it to an existing installation on your system. This ensures your project compiles and runs with the correct Java Development Kit.

Key Facts

Overview

Configuring the Java Development Kit (JDK) in IntelliJ IDEA is a fundamental step for any Java development project. The JDK provides the necessary tools, such as the compiler and debugger, that IntelliJ IDEA utilizes to build and run your Java applications. Whether you are starting a new project or working on an existing one, ensuring IntelliJ IDEA is aware of and correctly configured with your desired JDK is crucial for a smooth development workflow.

Why is JDK Configuration Important?

The JDK is the core component that enables you to write, compile, and execute Java code. It includes the Java Runtime Environment (JRE), which is necessary for running Java applications, and development tools like the compiler (javac) and the debugger (jdb). Without a properly configured JDK, IntelliJ IDEA cannot perform these essential tasks, leading to compilation errors, runtime issues, and an inability to debug your code effectively. Different projects might also require specific JDK versions due to compatibility with libraries, frameworks, or older codebases.

How to Configure a JDK in IntelliJ IDEA

IntelliJ IDEA offers a flexible and user-friendly way to manage your JDK configurations. You can set a JDK for a specific project or establish a global default that will be used for new projects.

Setting a JDK for a New Project

When you create a new Java project in IntelliJ IDEA, you will be prompted to select a JDK. If you don't have one already configured, IntelliJ IDEA provides convenient options:

  1. Download JDK: IntelliJ IDEA can automatically download and install compatible JDK distributions from various vendors (like Oracle OpenJDK, Adoptium Temurin, etc.). This is often the easiest method if you don't have a JDK installed or want a specific version. Click the 'Download JDK...' button and select your preferred vendor and version.
  2. Add JDK: If you have already downloaded and installed a JDK on your system, you can point IntelliJ IDEA to its location. Click the 'Add JDK...' button, navigate to the root directory of your JDK installation (the directory containing the 'bin' and 'lib' folders), and select it.
  3. Use Project SDK: For existing projects, you can select the 'Use Project SDK' option if a suitable JDK is already associated with the project.

Setting or Changing a JDK for an Existing Project

For projects you've already created, you might need to change or verify the JDK configuration. This is typically done through the Project Structure settings:

  1. Navigate to File > Project Structure... (or use the shortcut Ctrl+Alt+Shift+S on Windows/Linux, Cmd+; on macOS).
  2. In the Project Structure dialog, select Project from the left-hand menu.
  3. Under the 'Project SDK' dropdown, you will see a list of configured JDKs. Select the desired JDK from the list.
  4. If the JDK you want is not listed, click the 'Add SDK' button (usually represented by a '+' icon) and choose 'JDK'. Then, navigate to the directory where your JDK is installed.
  5. Once you have selected or added the desired JDK, click 'Apply' and then 'OK' to save the changes.

Global JDK Settings

IntelliJ IDEA also allows you to manage global JDK settings, which can define the default JDK for newly created projects. This is useful if you primarily work with one specific JDK version.

  1. Go to File > Settings... (or IntelliJ IDEA > Preferences... on macOS).
  2. Navigate to Build, Execution, Deployment > Build Tools > Gradle (if using Gradle) or Build, Execution, Deployment > Compiler > Java Compiler.
  3. Here you can often find settings related to default JDKs or SDKs. For more direct management of all SDKs IntelliJ IDEA knows about, you can go back to File > Project Structure... > SDKs (under Platform Settings).
  4. In the 'SDKs' pane, you can add, remove, or reorder JDKs. The order might influence which JDK is picked by default in certain scenarios.

Troubleshooting Common JDK Issues

Occasionally, you might encounter problems related to JDK configuration. Here are some common issues and their solutions:

By following these steps, you can effectively configure and manage your JDK within IntelliJ IDEA, ensuring that your Java development environment is set up correctly for optimal performance and productivity.

Sources

  1. Java Development Kit - WikipediaCC-BY-SA-4.0
  2. SDKs and JDKs in IntelliJ IDEA - JetBrains Documentationfair-use
  3. OpenJDK - Official Home of the Open Java Development Kitfair-use

Missing an answer?

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