Matthew
Matthew

Reputation: 69

I don't know why the intellij language level doesn't work

I am using Intellij for coding java but the problem is it always displays

invalid source release: 9

every time. I know that in order to fix it is to go to the project structure and change the level from 9 to 8. However, every time I make a new module I have to change the module language level since the default is 9.

  1. How can I change the default language level? I've changed the Project language level just like the picture but it didn't work.
  2. I thought it might solve the problem by changing the version of java to 9 but it didn't work. Why??

Upvotes: 7

Views: 4148

Answers (1)

When compiling Java program in IntelliJ Idea we might encounter the above error if the Java version is not properly set inside the editor.

Following the list of steps that you need to verify in order to compile your code correctly!

1) Go to File -> Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler

Here change the Project bytecode version to 1.8 or lesser. This changes the target release version.

2) Go to File -> Project Structure -> Modules -> Tab: Source: Language Level

Here change the language level to 1.8 or lesser. This changes the source release version.

3) Also, change the source release version to 1.8 by going to:

File -> Project Structure -> Project(In left pane) -> set "Project language level" to SDK Default (8 – Lambdas, type annotation, etc.)

Voila, now you are ready to start compiling your Java program.

Upvotes: 3

Related Questions