303

I use IntelliJ IDEA as my development environment, and Maven for dependency management. I frequently build my project structure (directories, poms, etc) outside of IDEA and then import the project into IDEA using Import project from external model. This works great, except that in my poms I specify that the maven-compiler-plugin should use JDK 1.6, and when I import, IDEA informs me that the Language Level Changed and that Language level changes will take effect on project reload, and then prompts to reload the project. This is annoying because I always use the same JDK version.

How do I change the default JDK that IntelliJ IDEA uses, so that I don't have to reload my project every time I import a new project?

12 Answers 12

371

This setting is changed in the "Structure for New Projects" dialog. Navigate to "File" -> "New Projects Setup" -> "Structure..."

Selecting Structure For New Projects

Next, modify the "Project SDK" and "Project Language Level" as appropriate.

Selecting Project Language Level


Previous versions of IntelliJ IDEA had this setting in "File" -> "Other Settings" -> "Default Project Structure...".

IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."

5
  • 8
    Jetbrains, Eclipse, Oracle etc should get together and set a standard for IDE configurations, hotkey combos etc. Then we devs could just remain productive when jumping from one IDE to another.
    – Adam
    Commented Aug 23, 2017 at 12:26
  • 3
    May I ask IntelliJ IDEA to use my %JAVA_HOME% system variable as a value of JDK home path? I want IntelliJ IDEA to reflect changes of JAVA_HOME sys variable automatically. Commented Nov 16, 2017 at 10:48
  • 3
    I think intellij should rename the menu entry 'file' to 'Project'. There are so many project specific things under file.
    – coder247
    Commented Jun 11, 2019 at 12:45
  • In the default window that opens when running IntelliJ IDEA (the project selector), on MacOS you can also hit ; to open the Project Structure for New Projects settings.
    – Erik
    Commented May 8, 2023 at 10:57
  • Sometime I wonder if the developper was drunk when implementing this functionnality. Jvm path? -> File/new project setup/structure, then exit, open switch to project configuration File/Project Strusture/project settings/project/SDK AND Platform settings/SDK + so logical!
    – pdem
    Commented May 16 at 15:05
75

Download and unpack a JDK archive file (.tar.gz) and add it as a SDK in the 'Project Structure' dialog box ( Ctrl+Alt+Shift+S )

jdk 9 intellij click on the gif to enlarge

Also make sure to set an appropriate 'Project language level'. I forgot to do that when creating the GIF.

Project Structure > Project > Project language level

For Java 8 set it to 8, for Java 9 set it to 9, and so on.

1
  • 1
    how to create this kind of gif?
    – shortduck
    Commented Oct 12, 2023 at 15:38
58
  • I am using IntelliJ IDEA 14.0.3, and I also have same question. Choose menu File \ Other Settings \ Default Project Structure...

enter image description here

  • Choose Project tab, section Project language level, choose level from dropdown list, this setting is default for all new project.

    enter image description here
31

I have found out that in recent versions of IntelliJ IDEA requires Java 1.8 but is not configured by default.

We can change the path or configure from Project Settings > Project > Project SDK

here we can edit or add the JDK´s path.

(in my case the path is located in C:\Program Files\Java\jdk1.8.0_102)

enter image description here

enter image description here

21

Change JDK version to 1.8

  1. Language level File -> project Structure -> Modules -> Sources -> Language level -> 8-Lambdas, type annotations etc. enter image description here
  2. Project SDk File -> project Structure -> Project 1.8 enter image description here

  3. Java compiler File -> Settings -> Build, Executions, Deployment -> Compiler -> Java compiler enter image description here

1
  • 2
    This does not address the default settings: see the accepted answer. Commented Jan 3, 2017 at 22:14
11

One other place worth checking: Look in the pom.xml for your project, if you are using Maven compiler plugin, at the source/target config and make sure it is the desired version of Java. I found that I had 1.7 in the following; I changed it to 1.8 and then everything compiled correctly in IntelliJ.

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
            <encoding>UTF-8</encoding>
        </configuration>
    </plugin>
</plugins>
</build>
5

The above responses were very useful, but after all settings, the project was running with the wrong version. Finally, I noticed that it can be also configured in the Dependencies window. Idea 2018.1.3 File -> Project Structure -> Modules -> Sources and Dependencies.

5

To change the JDK version of the Intellij-IDE himself:

Start the IDE -> Help -> Find Action

than type:

Switch Boot JDK

or (depend on your version)

Switch IDE boot JDK
3
  • 2
    In case IntelliJ doesn't start after that, edit the content of ~/Library/Preferences/IntelliJIdea2018.2/idea.jdk . from: intellij-support.jetbrains.com/hc/en-us/community/posts/…
    – Daniel
    Commented Oct 3, 2019 at 3:55
  • Clarification: as of IntelliJ 2020.3.4 this action does not seem available; I bet it finds the startup JDK automatically, or uses the included jbr(jre?) in the IntelliJ binaries directory. That is, you cannot switch it. There are no actions for 'Boot', basically
    – Jordan Gee
    Commented Oct 20, 2021 at 22:23
  • 1
    @JordanGee In 2021.x you can search for this action Choose Boot Java Runtime for the IDE... If the IDE crash on startup you can remove the jdk config, by removing this file ~/Library/Application\ Support/JetBrains/IntelliJIdea2021.3/idea.jdk
    – bric3
    Commented Nov 3, 2021 at 21:39
5

I am using IntelliJ 2020.3.1 and the File > Other Settings... menu option has disappeared. I went to Settings in the usual way and searched for "jdk". Under Build, Execution, Deployment > Build Tools > Maven > Importing I found the the setting that will solve my specific issue:

JDK for importer.

IntelliJ 2020.3 Settings dialog

4

For latest version intellij, to set default jdk/sdk for new projects go to

Configure->Structure for New Projects -> Project Settings -> Project SDK

2
  • 1
    Where did you find "Configure"? I'm using IntelliJ 2020 and cant fint it. Commented Mar 8, 2021 at 8:43
  • @GrgKro See my answer below. I had to hunt for it but documented what I did do with a picture...
    – cptully
    Commented May 14, 2021 at 13:17
0

On my linux machine I use a script like this:

export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh
0

This worked for me for Intellij Idea Version 2022.3.3

File -> New Projects Setup -> Structure

SDK: 1.8

Language Level: SDK default(8 Lambdas, type annotation etc)

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.