Home > Back-end >  IntelliJ 2021.2.2 gives error 'java: error: invalid source release: 18' when compiling pro
IntelliJ 2021.2.2 gives error 'java: error: invalid source release: 18' when compiling pro

Time:10-03

I've looked trough many answers here on so but haven't found anything helpful. I am using java version 16.0.1 My program doesn't use maven or gradle. The program worked fine until I updated my ij earlier today.

Full error:

    Executing pre-compile tasks...
    Loading Ant configuration...
    Running Ant tasks...
    Running 'before' tasks
    Checking sources
    Parsing java... [Adexo]
    java: error: invalid source release: 18
    Checking dependencies... [Adexo]
    Dependency analysis found 0 affected files
    Errors occurred while compiling module 'Adexo'
    javac 11 was used to compile java sources
    Finished, saving caches...
    Module 'Adexo' was fully rebuilt due to project configuration/dependencies changes
    Compilation failed: errors: 1; warnings: 0
    Executing post-compile tasks...
    Loading Ant configuration...
    Running Ant tasks...
    Synchronizing output directories...

    30.9.2021 22:34 - Build completed with 1 error and 0 warnings in 3 sec, 279 ms

Project Modules Java Compiler

Here are the files from .idea and the .iml file: https://1drv.ms/u/s!AoGu278qdPOWgm-D3ns61-gqA4Ts?e=OWg0NB

Please tell if you need any more information (:

CodePudding user response:

.idea/misc.xml has incorrect language level specified for some reason (JDK_X):

<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">

Close the project, change languageLevel to 16 and see if it helps.

There was a related bug reported, but it should be fixed in IntelliJ IDEA 2020.2 and later versions. Probably a regression.

  • Related