I have a project with MANY modules. We\'re upgrading to Java7, and I want my editor to reflect this. Now all my modules specifically set the language level to Java6, and there a
As pointed out in the comment by Lambart to the other answer, the solution doesn't work for changing the target version for all the modules altogether.
Also, observe that setting the target level for the project is fine, but this target version is overridden by the one specified in a module.
If you, like me, are unlucky and need to work on a 100+ modules Java monolith, then changing modules one by one will be a pain.
My solution is "annoying" but works under LINUX. I assume in the example that you want to update form 1.5 to 1.8.
Step 1) You have to go in the .idea
folder and look for the file compiler.xml
.
Replace all the target
values in the tag <module>
, e.g.
target="1.5"
to
target="1.8"
Step 2) go in the project folder and run the following script
find . -type f -name "*.iml" -print0 | xargs -0 sed -i "s/JDK_1_5/JDK_1_8/g"
to replace all the language level in the modules to be JDK8 compliant.
In IntelliJ IDEA 14.0, go to File | Project Structure | Modules (Ctrl+Shift+Alt+S).
The list of modules supports multiple selection so
Select in the drop-down menu Language level and choose manually the level or "Use project language level".
Similarly to change the language level for the project, select project in the ribbon on the left under Project Settings. A drop down menu is available for Project language level. Choose the level needed. This will set the default for all project modules.
The other solutions didn't worked for me, even after modifying by hand the compiler.xml
and all the .iml
files the the LANGUAGE_LEVEL
was still set to "JDK_1_5"
. This was caused by the maven-compiler-plugin
plugin's configuration
option.
Changing it to the following fixed it:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Hope this solves it for others also.