Advertisements
RSS

How to set the default Java version in IntelliJ IDE projects

16 Jan

When working in a Java environment with multiple developers using their own IDE preference I often get error like this opening a project with IntelliJ: “@Override is not allowed when implementing interface method”. Since I’m not a Java dev fulltime I tend to forget this stuff, so basically this is a reminder for myself …

Basically IntelliJ thinks the project is Java 1.5 by default so while my console / mvn build works perfectly due to using Java 8 the IDE thinks differently.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
  </configuration>
</plugin>

Project Language

File > Project Structure > Project > Language level

Module Language

If your project has multiple modules check that they inherit the project language, or when needed, set the correct non-default on the module

File > Project Structure > Module > Language level

or

Right Click module > Open Module Settings 


Java Compiler for Default Projects

While your at it, set this value as a default for new projects as well

File > Other Settiings > Default Settings > Build, Execution, Deployment > Compiler > Java Compiler > Project Bytecode version

 

Advertisements
 
Leave a comment

Posted by on 16-01-2018 in Uncategorized

 

Tags: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: