Intellij Java Error Release Version 5 Not Supported

1 view
Skip to first unread message

Luciana

unread,
Aug 5, 2024, 5:37:51 AM8/5/24
to beausucaca
Ihad similar issue except that the error was "release version 5 not supported. " I tried all of the above and other proposed solutions but nothing worked, except putting following xml into the pom.xml file:

Probably your IntelliJ IDEA previously used Java 8. Starting from java 9 Java, instead of having 2 parts, jdk and jre, Java has only one, the jdk. I have got the same error message when I switched from java 8 to java 11. So you have to switch the IntelliJ IDEA to the new Java version.


The . idea folder (hidden on OS X) in the solution root contains IntelliJ's project specific settings files. These include per-project details such as VCS mapping and run and debug configurations, as well as per-user details, such as currently open files, navigation history and currently selected configurations.


When upgrading the Java/JDK version in a Maven project, we may encounter the error that a specific release version X is not supported. In this article, we will learn to fix this error and understand the root cause behind this exception.


I encountered this error when upgrading an application from Java 17 to Java 21. I was using the IntelliJ idea IDE, although it does not matter much. You can encounter this issue in other IDEs as well as in the terminal/command line as well.


This short Java tutorial discussed the root cause and the solution behind the error Maven-compiler-plugin: release version not supported. This can happen for any release of Java version when we upgrade the project dependencies.


It is also great to see how all these Java features, release after release, work together to create more possibilities and have a bigger impact on how developers create their applications that address existing pain points, perform better and are more secure.


String Templates (Preview Language feature)

The existing String concatenation options are difficult to work with and could be error prone; String templates offer a better alternative, that is, String interpolation with additional benefits such as validation, security and transformations via template processors.


You could replace the preceding code with either StringBuilder.append(), String.format() or String.formatted() method or by using the class MessageFormat (as shown in my detailed blog post on this topic), but each of these methods have their own issues.


Using String Templates with Text Blocks

Text blocks are quite helpful when working with string values that span multiple lines, such as, JSON, XML, HTML, SQL or other values that are usually processed by external environments. It is common for us Java developers to create such string values using a combination of string literals and variable values (variables, expressions or method calls).


The example below shows how IntelliJ IDEA could detect and create a text block using String templates for multiline string values that concatenates string literals with variable values. It also shows how IntelliJ IDEA provides code completion for variable names within such blocks. When you type in \, IntelliJ IDEA adds . As you start typing the variable name countryName, it shows the available variables in that context:


Language injection and String Templates

You could also inject a language or a reference in string values that spans single line or multiple lines, such as, a text block. By doing so, you get comprehensive coding assistance to edit the literal value. You could avail of this feature temporarily or permanently by using the @Language annotation, as shown below:


Depending on the logic of your application, you might want to escape, delete or throw errors for the special characters that you encounter in the the JSON values interpolated via template expressions, as follows (the following method chooses to escape the special characters and include them as part of the JSON value):


On the command prompt, you could use the javac and java commands to compile and execute your code. Assuming you have defined your code in a source code file HelloWorld.java, you could use the following commands to run and execute it:


Since Java 11, it is possible to skip the compilation process for code defined in a single source code file, so you could use just the second command (by specifying the name of the source code file, as follows):


The idea to include multiple examples as listed above is to demonstrate the power of sequence, condition and iteration all of which can be included in the main() method, to build good programming foundations with problem solving skills. By using the run command or the icon to run and execute their code in IntelliJ IDEA, new programmers reduce another step when getting started.


When you are ready to level up and work with other concepts like user defined classes, you could also covert the implicit classes and code that we used in the previous examples, to regular classes, as shown below:


If you are an educator, you could introduce your students to other commonly used programming practices, such as creating methods- that is delegating part of your code to another method and calling it from the main method. You could also talk about passing values vs. variables to these methods.


Typically, we create alternative solutions for tasks that are necessary, but not officially permitted. For instance, executing statements before super() in a derived class constructor was not officially allowed, even though it was important for, say, validating values being passed to the base class constructor. A popular workaround involved creating static methods to validate values and then calling these methods on the arguments of super(). Though this approach worked well, it could make the code look complicated. This is changing with Statements before super(), a preview language feature in Java 22.


By using this feature, you can opt for a more direct approach, that is, drop the workaround of creating static methods, and execute code that validates arguments, just before calling super(). Terms and conditions still apply, such as, not accessing instance members of a derived class before execution of super() completes.


The constructor of the class Element misses checking if the atomicNumber is in the range of 1-118 (all known elements have atomic numbers between 1 to 118). Often the source code of a base class is not accessible or open for modification. How would you validate the values passed to atomicNumber in the constructor of class IndustryElement?


The most important point to note here is that in both the cases, the constructor of the base class, that is, Element is called, after the execution of all other statements. Essentially, it means, you are still doing the same thing, it is just packaged in a way that makes things easier for you.


I understand it is difficult to remember what each of these instruction codes means. Access the following link and search for the instruction code and following the above instructions set would be a breeze:


In the previous example, the patterns int x, int y, Point a and Point B (for case label Line) remain unused as detected by IntelliJ IDEA. These could be replaced by an _. Also, since all the record components of the case Point remain unused, it could be replaced as Point _. This could also allow us to merge the first and second case labels. All of these steps are shown in the following gif:


Because of how these features work, IntelliJ IDEA is committed to only supporting preview features for the current JDK. Preview language features can change across Java versions, until they are dropped or added as a standard language feature. Code that uses a preview language feature from an older release of the Java SE Platform might not compile or run on a newer release.


String Templates is a great addition to Java. Apart from helping developers to work with strings that combine string constants and variables, they provide a layer of security. Custom String templates can be created with ease to accomplish multiple tasks, such as, to decipher letter combinations, either ignoring them or replacing them for added security.


Java language designers are reducing the ceremony that is required to write the first HelloWorld code for Java students, by introducing implicitly declared classes and instance main methods. New students can start with bare minimum main() method, such as, void main() and build strong programming foundation by polishing their skills with basics like sequence, selection and iteration.


By submitting this form, I agree that JetBrains s.r.o. ("JetBrains") may use my name, email address, and location data to send me newsletters, including commercial communications, and to process my personal data for this purpose. I agree that JetBrains may process said data using third-party services for this purpose in accordance with the JetBrains Privacy Policy. I understand that I can revoke this consent at any time in my profile. In addition, an unsubscribe link is included in each email.


Since my colleagues meanwhile get the same error we decided to estimate this issue a bit deeper.

SonarLint plugin version is now 4.1.1.3345.

Running with the configuration from my post above we found this in the log:


As far as I can tell, there is no way to tell SonarJava to load Java standard library classes from another version than the one it is running with, hence my advice to upgrade SonarJava to a version that supports Java 11.


You can select IntelliJ runtime :

IDEs Support (IntelliJ Platform) JetBrains Selecting the JDK version the IDE will run underJava 8Please be aware that Java 8 is required to run IntelliJ IDEA starting from version 2016 on all the supported platforms. It also applies to the lightweight IDEs based on IntelliJ platform rel...


This error typically occurs when trying to compile or run Java code using a Java Development Kit (JDK) version that does not support the specified release version, in this case, version 17. It indicates that the JDK being used is outdated and does not recognize the features introduced in Java 17.

3a8082e126
Reply all
Reply to author
Forward
0 new messages