Java version keeps getting reset to 1.5 when I change something (libraries in Project Settings?)

Answered

Something is changing Java versions on me - from my selected 1.8 to 1.5. I need to fix this in two places

  1. Project Settings -> Modules -> Sources and set language level
  2. .idea/compiler.xml: change <module name="DroolsGameEngine" target="1.5" /> to 1.8

I think this is when I modify libraries via Project Settings. Whatever the cause, I would like to be able to change this default 1.5 to 1.8, but I don't know where to look to achieve this. Any pointers most welcome.

Thanks,

11
39 comments

Please share a sample project https://uploads.services.jetbrains.com/ and the screenshot from the project structure | modules dialog showing the language level selected for the module.

0
Avatar
Permanently deleted user

I am also having this problem:

pom.xml:

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
...

Module Settings:


Right Click on Module / rebuild module:




The module is part of a project with language level 1.6.
0

Please report at https://youtrack.jetbrains.com/newIssue?project=IDEA and proivde a small sample project to reproduce the issue.

0
mine is very similar (see below for trivial differences).
When I first had the problem I had to manually edit the ./idea/compiler.xml file and set all the targets correctly.
/compiler.xml:  <module name="parent" target="1.11" />
I have not had any issues since using the below configuration in our parent pom.xml
<java.release>11</java.release>
<java.version>1.${java.release}</java.version>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
<version>3.8.1</version>
<configuration>
<release>${java.release}</release>
</configuration>
0
Avatar
Permanently deleted user

I had to use older version 2017.#.# becase of the project , and Intellij is giving me nightmares. unbelievable that Intellij assumes compiler is 1.5 [in modules]. Is it not very much fundamental. once this is done...all spring code becomes red. Hate this editor.

0

>Intellij assumes compiler is 1.5

Maven defaults to 1.5 version unless you explicitly set it in pom.xml. Please see https://stackoverflow.com/a/12900859/2000323

0
Avatar
Permanently deleted user

I had to change - Project Structure -> Modules -> Sources and set language level

even after maven source and target java version were added as 1.8 to properties in pom. Anyways it is community edition, so presume there will lots of issues. sometimes - %MODULE_WORKING_DIRECTORY% issue, as if it doesn't know what it looks for.

0

Community and Ultimate editions have equal Maven support except for Maven dependency diagrams.

>I had to change - Project Structure -> Modules -> Sources and set language level even after maven source and target java version were added as 1.8 to properties in pom. 

If you have this issue with the latest version please report at https://youtrack.jetbrains.com/issues/IDEA with the same project configuration. We will investigate. Thanks.

>sometimes - %MODULE_WORKING_DIRECTORY% issue, as if it doesn't know what it looks for.

There is no such macro path as %MODULE_WORKING_DIRECTORY%. There are %MODULE_WORKING_DIR% (has been added since 2018.2) and $MODULE_DIR$. Please see this comment for more info.

0

I just had this problem, fixed it by deleting the project and reimporting from vcs. Version 2021.1.3

0

Please sign in to leave a comment.