Reputation: 3627
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?
Upvotes: 307
Views: 531434
Reputation: 730
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)
Upvotes: 0
Reputation: 13715
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 )
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.
Upvotes: 83
Reputation: 3627
This setting is changed in the "Structure for New Projects" dialog. Navigate to "File" -> "New Projects Setup" -> "Structure..."
Next, modify the "Project SDK" and "Project Language Level" as appropriate.
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..."
Upvotes: 376
Reputation: 697
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.
Upvotes: 5
Reputation: 10808
On my linux machine I use a script like this:
export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh
Upvotes: 0
Reputation: 759
For latest version intellij, to set default jdk/sdk for new projects go to
Configure->Structure for New Projects -> Project Settings -> Project SDK
Upvotes: 4
Reputation: 3099
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
Upvotes: 5
Reputation: 4552
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>
Upvotes: 11
Reputation: 51
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.
Upvotes: 5
Reputation: 126445
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
)
Upvotes: 32
Reputation: 2299
Change JDK version to 1.8
Java compiler File -> Settings -> Build, Executions, Deployment -> Compiler -> Java compiler
Upvotes: 21
Reputation: 52438
File
\ Other Settings
\ Default Project Structure...
Project
tab, section Project language level
, choose level from dropdown list, this setting is default for all new project
.Upvotes: 59