Главная » Error » IntelliJ IDEA

IntelliJ IDEA

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” class=”wp-image-12920″ sizes=”(max-width: 1464px) 100vw, 1464px”><br /><img loading=
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.

class=”mini-divider”>

Other Popular Articles…

  1. IntelliJ IDEA Project/Module and latest Java setup (Java 17 or newer)
  2. How to Install and Configure Elasticsearch on your Dev/Production environment?
  3. How to create Java Maven Project and push it to Github from IntelliJ IDEA without any Git Client?
  4. What is pom.xml (Project Object Model)? Sample pom.xml for you to use in your Dynamic Web Project (Java / J2EE)
  5. How to create 1st Spring Boot HelloWorld Application in IntelliJ IDEA with few simple steps?
  6. IntelliJ IDEA – Top 5 Themes

Design Development Technology & Tools IntelliJ IDE

<хедер class="section-хедер hide-on-mobile crunchify-full-width" style="margin-top:50px;">

2. Fix invalid target release error by changing Maven’s Java version

Apply this solution if the project’s Java version cannot be lower. That means you need to have another JDK newer than the one that runs Maven. You can check by typing:

java -version

Or:

mvn -v

You need to install a newer JDK and then update JAVA_HOME or PATH environment variables. Follow my guides here (for example, install JDK 17):

  • Download and install Oracle JDK 17
  • How to set JAVA_HOME environment variable

Note that you need to open a new command prompt window after updating the environment variables.

Solution 3 : try to change the Java version

Here First of all set the language level/release versions in pom.xml Like this.

1.8
1.8

Then Just try to change the Java version.

  1. Go to File -> Select Project structure -> Select Project -> Then Project SDK -> set It to 11
  2. Go to File -> Select Project structure -> Select Project -> Select Project language level  -> set to 11
  3. Go to File -> Select Project structure -> Select Project -> Select Modules -> select Sources  -> set it to 11
  4. Go to setting -> Open Build, Execution, Deployment -> Slect Compiler -> Then select Java Compiler -> Change Project bytecode version to 11
  5. Go to setting -> Open Build, Execution, Deployment -> Slect Compiler -> Then select Java Compiler -> Select Module -> Change it to 11

Правильные Решения

Итак, ваш JDK слишком новый, чтобы генерировать двоичные файлы Java 5. Есть два решения для решения этой проблемы.

Используйте более старый JDK

Как упоминалось ранее, JDK9 отказался от поддержки кросс-компиляции в двоичные файлы Java 5. Это означает, что до тех пор, пока вы используете JDK 8 или ниже, вы действительно можете создавать двоичные файлы Java 5. Однако этот метод НЕ рекомендуется. Не должно быть никаких причин придерживаться Java 5 в рабочей среде выполнения. JDK 5 не поддерживается с 2015 года, и исправления безопасности больше не предоставляются.

Измените желаемый уровень целевого языка

Вместо кросс-компиляции в двоичные файлы Java 5 вам следует создавать двоичные файлы, соответствующие версии рабочей среды Java runtime environment. Это должно быть по крайней мере Java 8 до 2023 года, чтобы получить исправления безопасности. Смотрите также Историю версий Java в Википедии. Тем не менее, я рекомендую использовать Java 11, чтобы использовать различные новые функции, введенные между ними, и в то же время оставаться на версии LTS.

Итак, как же тогда изменить целевую версию?

Проекты на основе Maven

По очень веским причинам Maven по-прежнему широко используется в экосистеме Java. Однако Maven довольно старый, как и некоторые настройки по умолчанию. Одним из которых является уровень языка, который по умолчанию равен Java 1.5, независимо от используемого вами JDK.

В обычных проектах Maven вы можете вставить вышеупомянутый код в свой конфигурационный файл сборки pom.xml чтобы установить уровень целевого языка.

1.81.8

В проектах Spring Boot код немного меняется на

1.8

После изменения pom.xml вам необходимо повторно импортировать все проекты Maven в IntelliJ IDEA. Самый простой способ сделать это – нажать cmd + shift + A (shift + ctrl + A в Windows/Linux), а затем просто начать печатать.

How Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate Occurs ?

Today I am just trying to run my simple java maven project in my IntelliJ IDEA Ultimate And I am facing the following error.

Error:java: error: release version 5 not supported

2. Solution – Update JAVA_HOME

Updating the JAVA_HOME environment variable and ensuring it points to the correct JDK.

2.1 For macOS, open the ~/.zshenv and update the JAVA_HOME to Java 17

The JAVA_HOME is pointing to Java 11.

~/.zshenv
export JAVA_HOME=$(/usr/libexec/java_home -v 11)

We upgraded the JAVA_HOME to Java 17.

~/.zshenv
export JAVA_HOME=$(/usr/libexec/java_home -v 17)

2.2 source the ~/.zshenv or reopen the shell to reflect the change of the JAVA_HOME.

Terminal
source ~/.zshenv

2.3 Recheck Maven’s Java version.

Terminal
mvn -version

Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: /usr/local/Cellar/maven/3.8.3/libexec
Java version: 17, vendor: Oracle Corporation, runtime: /Users/yongmookkim/Library/Java/JavaVirtualMachines/openjdk-17/Contents/Home
Default locale: en_MY, platform encoding: UTF-8
OS name: “mac os x”, version: “11.6”, arch: “x86_64”, family: “mac”

Note
For Windows or Linux, find the JAVA_HOME environment variable and ensure it is pointing to the correct JDK.

How To Solve Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate?

  1. How To Solve Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate?

    To Solve Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate Open Your IDE Setting. Then Open Build Execution, Deployment Then Select Compiler. Then Just Scroll down to Maven and java compile In the right panel will be a list of modules and their associated java compile version “target bytecode version.” Select a version >1.5. You may need to upgrade your JDK if one is not available. Preferences > Build, Execution, Deployment > Compiler > Java Compiler > Target bytecode version. Setting this value fixed the error for me

  2. Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate

    To Solve Error:java: error: release version 5 not supported in IntelliJ IDEA Ultimate Open Your IDE Setting. Then Open Build Execution, Deployment Then Select Compiler. Then Just Scroll down to Maven and java compile In the right panel will be a list of modules and their associated java compile version “target bytecode version.” Select a version >1.5. You may need to upgrade your JDK if one is not available. Preferences > Build, Execution, Deployment > Compiler > Java Compiler > Target bytecode version. Setting this value fixed the error for me

Solution 2: Add this code in build plugin in POM file

1.8
3.8.1
1.8
1.8

org.apache.maven.plugins
maven-compiler-plugin
${maven.compiler.version}
${java.version}
${java.version}

Solution 1: Change target bytecode version

  1. Open Your IDE Setting.
  2. Then Open Build Excecution, Deployment
  3. Then Select Compiler.
  4. Then Just Scroll down to Maven and java compile
  5. In the right panel will be a list of modules and their associated java compile version “target bytecode version.”
  6. Select a version >1.5.
  7. You may need to upgrade your jdk if one is not available.
  8. Preferences > Build, Execution, Deployment > Compiler > Java Compiler > Target bytecode version. Setting this value fixed the error for me

3. Fix invalid target release error in IDE

If you encounter the Maven error invalid target release in your IDE such as Eclipse or Spring Tool Suite, follow these steps:

– Open the Run Configurations dialog (Go to menu Run > Run Configurations)

– Select the Run configuration that you use to run Maven build

– Click JRE tab. Then choose the Runtime JRE that has version greater than or equal to your project’s Java version.

edit run configuration maven

Refer to this article to learn more: How to manage JRE installations in Eclipse.

To see how to fix the Maven build error invalid target release in action, watch the following video:

Video:

 

Источники

  • https://crunchify.com/intellij-idea-how-to-set-latest-java-sdk-and-fix-an-error-errorjava-error-release-version-14-not-supported/
  • https://www.codejava.net/tools/maven/fix-error-invalid-target-release
  • https://exerror.com/errorjava-error-release-version-5-not-supported-in-intellij-idea-ultimate/
  • https://javascopes.com/proper-solutions-for-error-java-release-version-5-not-supported-4m5f-98a40eb5/
  • https://mkyong.com/maven/maven-error-invalid-target-release-17/
[свернуть]
Решите Вашу проблему!


×
Adblock
detector