Error java invalid source release 11

When try to compile your Java code on IntelliJ, you may get the annoying java: invalid source release: 8 error . The complete error is as follows

The reason is that your project/module JDK version does not match the intellij project version and below steps to fix it :

  1. Open your IntelliJ and navigate to File ->Project Structure ->Project Settings (Ctrl + Alt + Shift + S)
  2. In the Project SDK section, select the SDK that matches your code. (My code targets Java 1.8, so I select Java 1.8)

That’s it. Your project should build without problem now.

I am trying to build an application which was built using java 8, now it’s upgraded to java 11. I installed Java 11 using an oracle article in my windows machine and I use IntelliJ IDEA 2017 as my IDE.

I changed my system environment variables and set the

And added that to the Path variable.

When I build my application in IntelliJ, this is what I get:

This is what I’ve tried so far:

I changed .idea/compiler.xml target values from 8 to 11 but that didn’t help. Also, verified the Target bytecode version in settings > Build, Execution, Deployment > Compiler > Java Compiler and all my modules are set to 11.

Went to file > Project Structure > SDKs *(currently I have 1.7 and 1.7 listed)* > Add new SDK > JDK > After that, I selected C:Program FilesJavajdk-11.0.1 But it errors out with "The selected directory is not a valid home for JDK"

Читайте также:  Чей перевод хоббита лучше

I am not sure if I installed the wrong JDK 11, because in my C:Program FilesJava , I see separate JDK and JRE folders for 1.7 and 1.8 but only JDK folder for 11.0.1

Comments

Copy link Quote reply

NTMS2017 commented Nov 12, 2018

When I try to build my Flutter project I get:

  • Error java invalid source release 11

I upgrade the Flutter today, rest of the details in below:

OS: macOS Mojave 10.14.1
IDE: IntelliJ IDEA Community 2018.2.5
Build: #IC-182.4892.20, built on October 16, 2018
JRE: 1.8.0_152-release-1248-b19 x86_64
JVM: OpenJDK 64-Bit

Terminal:
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

This comment has been minimized.

Copy link Quote reply

zoechi commented Nov 12, 2018

Please add the output of flutter doctor -v .

This comment has been minimized.

Copy link Quote reply

NTMS2017 commented Nov 13, 2018

Thanks, I install jdk 11 and re configure the IDE and its working now. Bur I have a problem on hot-reload. First run always give me an error and is not showing what the error was. but second run I can see the my app loading inside the emulator. Since February lots of changes happenedin Flutter and Dart and I also update my mac to macos mojave. my mac is clean all the time that I dont put everything in it. Just the dart project and Flutter project that I am working. How good is, if I remove everything and clean install IDE to dart, flutter, android studio and xcode? I am nearly in phase to release my app. Which is most stable version of dart and flutter so I can run build to get ios and android output for publising?

Оцените статью
ПК Знаток
Добавить комментарий

Adblock
detector