How do I change the IntelliJ IDEA default JDK?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
IntelliJ IDEA, a popular Integrated Development Environment (IDE) for Java and many other programming languages, requires a Java Development Kit (JDK) to run and compile Java applications. By default, IntelliJ may use a bundled JDK version, but you might need to change the JDK version based on the requirements of your project or to use features available in a different JDK version.
Understanding JDK in IntelliJ IDEA
IntelliJ IDEA can configure JDKs at two levels - globally and per project. The global JDK affects all projects where a project-specific JDK is not defined. Changing the JDK at the project level allows you to configure a JDK specific for that project without altering other projects or global settings.
Changing the Global JDK Settings
To change the default JDK that IntelliJ uses globally, follow these steps:
- Open IntelliJ IDEA and navigate to the main menu.
- Click on
File > Project Structure > SDKs. - In the SDKs section, you will see a list of all configured SDKs in your IntelliJ. If the JDK you want to use is not listed, you will need to add it.
- To add a new JDK, click on the
+icon and selectJDK. Then, navigate to the directory where the JDK is installed on your computer and select it. IntelliJ will validate the JDK and add it to the list. - Once added, you can select it for any project or set it as the default SDK by using it in project settings.
Changing the JDK for a Specific Project
If you only need to change the JDK for a single project, follow these steps:
- Open your project in IntelliJ IDEA.
- Navigate to
File > Project Structure > Project. - In the Project SDK section, you can select an existing SDK from the drop-down menu, or add a new one by following similar steps as adding a global SDK.
- After selecting or adding the new JDK, apply the changes. This will change the JDK used for compiling and running the application within that specific project.
Checking and Configuring JDK for Run/Debug Configurations
Each run/debug configuration in IntelliJ can also specify which JDK or JRE to use. This is particularly useful when testing application compatibility with different Java versions.
- Go to
Run > Edit Configurations. - Select a configuration on the left panel.
- Under the
Configurationtab, you can find the option to select the JRE. Adjust it according to your needs for testing or running the application.
Automating JDK Configuration with Project Files
IntelliJ IDEA allows you to specify SDK settings in the project’s .idea folder, which can be particularly useful for maintaining consistent environment settings across multiple development environments. This is done through the misc.xml file where you can specify the project-level JDK.
Summary Table
Below is a summary of the key points discussed:
| Action | Path or Setting | Description |
| Adding a new Global JDK | File > Project Structure > SDKs | Add and select new JDK installations globally. |
| Changing Project JDK | File > Project Structure > Project | Change or select the JDK for the specific project. |
| Configuring Run Configurations | Run > Edit Configurations | Set specific JDK or JRE for different run configurations. |
| Automating SDK Settings | .idea/misc.xml | Specify JDK settings in project files for consistency across setups. |
Conclusion
Changing the JDK in IntelliJ IDEA is a straightforward process that can be done either globally or on a per-project basis. It allows developers to effectively manage different Java version requirements across various projects, enhancing productivity and ensuring compatibility. Always remember that updating to a newer JDK can provide better performance and more features, but it might also lead to compatibility issues with older applications, so it's important to test thoroughly after changes are made.
Related reading
- How do I check if a file exists in Java?
- How do I check if my EditText fields are empty?
- How do I check if the Java JDK is installed on Mac?
- How do I choose the URL for my Spring Boot webapp?
- How do I clone a generic List in Java?
- How do I Cluster Hibernate ORM Identifiers when using GenerationType.Table
- How do I compare strings in Java?
- How do I configure HikariCP in my Spring Boot app in my application.properties files?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.