Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

IntelliJ IDEA – How to Set Latest Java SDK and fix an Error: java: error: release version 14 not supported

$
0
0

How to fix an error Error java release version 14 not supported

Today while running my Java Program I got below error in IntelliJ IDEA.

Information:Too many modules require recompilation, forcing full project rebuild
Information:java: Errors occurred while compiling module 'CrunchifyTutorial'

Information:javac 11 was used to compile java sources
Information:7/19/20, 10:46 AM - Build completed with 1 error and 0 warnings in 2 s 331 ms

Error:java: error: release version 14 not supported

In addition to above problem, do you have any of below errors?

  • IntelliJ IDEA 2020.1 unable to compile with java 7
  • Error:java: invalid source release: 8 in Intellij. What does it mean?
  • Cannot compile to Java 8 with Java 11
  • Intellij insists on compiling with javac 11.0.3 instead of Java 9
  • IntelliJ IDEA tells me “Error:java: Compilation failed: internal java compiler error idea”

Then you are at right place.

Let’s get started on solving this error:

Step-1)

Make sure you have latest Java installed on your laptop/desktop. In my case, instead of installing Java I usually download full JDK binary and put it on my host.

Visit URL: https://www.oracle.com/java/technologies/javase-downloads.html to download latest JDK.

Java SE JDK Download

Download macOS Compressed Archive

Step-2)

Let’s install and set latest Java in your IntelliJ IDEA.

  1. Right click on Project
  2. Click on Open Module Settings
  3. Click on Project -> Project SDK
  4. Click on Dropdown
  5. Click on Add SDK
  6. Provide path of latest downloaded Java JDK
  7. Click on Project language level
  8. Set it to 14 - Switch expressions

IntelliJ IDEA - Open project Module Setting

Go to Project Settings -> Project -> Project SDK

Click on Add SDK

Provide path of newly added Java SDK

Set Project language level to 14 - switch expressions

By doing this, you have setup Java 14 correct way on your IntelliJ IDEA.

Step-3)

  • Go to IntelliJ IDEA
  • Click on Preferences
  • Go to Build, Execution, Deployment -> Compiler -> Java Compiler
  • Make sure below settings are set correctly
    • Use compiler: Javac
    • Project bytecode version: 14
    • Target bytecode version: 14 (for your module/project)
    • Click save

IntelliJ IDEA - set Java Compiler and Bytecode to 14

Step-4)

  1. Right click on Project
  2. Click on Open Module Settings
  3. Click on Project Settings
  4. Click on Modules
  5. Make sure you select your project. In my case it’s CrunchifyTutorial
  6. Click on Language level:
    • Select 14 – Switch expressions
  7. Click Save

IntelliJ IDEA - set module Language level to latest version

Step-5)

Now re-run your project and it should run without any issue.

Rebuild Project:

Build Successful - with Java 14 fix by Crunchify

Information: Too many modules require recompilation, forcing full project rebuild
Information: javac 14.0.2 was used to compile java sources
Information: 7/19/20, 12:09 PM - Build completed successfully in 2 s 310 ms

Run Sample Java Program:

/Users/crunchify/Desktop/installation/jdk-14.0.2.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=63228:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/crunchify/Documents/C/crunchify-github/CrunchifyTutorial/target/classes crunchify.com.tutorials.CrunchifyJava14

Hey.. You have setup Java 14 successfully in IntelliJ IDEA

Process finished with exit code 0

Please let me know if you have any other issue running Java program in your IntelliJ IDEA. We will try to provide answer at earliest convenience.

The post IntelliJ IDEA – How to Set Latest Java SDK and fix an Error: java: error: release version 14 not supported appeared first on Crunchify.


Viewing all articles
Browse latest Browse all 1037

Trending Articles