Java 21 features wont work [message #1862361] |
Tue, 28 November 2023 13:12  |
Eclipse User |
|
|
|
Hey!
I am rather new to Ecplipse and tried installing jdk 21 (from the oracle website) and created a new Java project in eclipse. As for the JRE I referenced the folder of the newly installed jdk21. Now I wanted to try out the new "switch" with using Typepatterns but Ecplipse gives me the error, that I only can use int, string,.. for a switch command. But well, in Java 21 it should be possible to also use objects.
If I print
System.out.println(System.getProperty("java.version"));
I get "21.0.1"
Therefor I now dont know what to try to fix that issue.
Does someone have an idea on how to handle that?
|
|
|
|
Re: Java 21 features wont work [message #1862991 is a reply to message #1862361] |
Wed, 10 January 2024 04:50  |
Eclipse User |
|
|
|
Vivien Born wrote on Tue, 28 November 2023 18:12Hey!
I am rather new to Ecplipse and tried installing jdk 21 (from the oracle website) and created a new Java project in eclipse. As for the JRE I referenced the folder of the newly installed jdk21. Now I wanted to try out the new "switch" with using Typepatterns but Ecplipse gives me the error, that I only can use int, string,.. for a switch command. But well, in Java 21 it should be possible to also use objects.tunnel rush
If I print
System.out.println(System.getProperty("java.version"));
I get "21.0.1"
Therefor I now dont know what to try to fix that issue.
Does someone have an idea on how to handle that?
The Pattern Matching for switch feature allows you to use pattern patterns in switch statements, which can match the type of an object. To use this feature in Eclipse, you need to ensure that you are using Java 21 as your compliance level compiler. After changing the compiler compliance level, you will be able to use the new conversion feature in your code.
If you are still having problems, I recommend checking that your JDK installation is configured correctly and that you have the latest version of Eclipse installed.
|
|
|
Powered by
FUDForum. Page generated in 0.06160 seconds