If you make use of the Java JDK 21 Preview Features in IntelliJ IDE you will see a compilation error, and also when you execute such code, you will see errors.
/Users/code2care/IdeaProjects/demo/src/Main.java:7:25
java: string templates are a preview feature and are disabled by default.
(use --enable-preview to enable string templates)
To enable preview features of Java JDK, you can follow the below step.
- Open Project Settings by pressing Command ⌘ + ; on Mac, or Ctrl+Alt+Shift+S if on Windows or Linux.
- Now for Language level: select "21 (Preview) - String templates, unnamed classes and instance main methods etc."
- You will see Experimental Feature Alert
- Close the Project Structure window.
- You will see that the complications errors are gone, and no errors in the console when you run the Java programs with preview features.
Click on Accept.
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Java-JDK-21,
- Installing Java JDK 21 Final Release Candidate
- Steps to Install Java 21 (LTS JDK) on Windows 11
- How to install and Use Java JDK 21 Initial Release Candidate
- How to Enable Java JDK 21 Preview Features on IntelliJ
- Setting Up VS Code with Java JDK 21
- Java JDK 21 LTS Version Release Date (General Availability)
- [JEP 430] Java JDK 21 New Feature - String Templates (Preview)
- How to use Java JDK 21 with IntelliJ
- Java JDK 21: JEP 439 - An Improved Generational Z Garbage Collector (ZGC)
- [JEP 431] Java JDK 21 New Feature - Sequenced Collections
- Java JDK 21 - The Latest LTS Version
- Java JDK 21 - JEP 440 - Record Patterns
- Fix - Unsupported major.minor version 65.0 (Java JDK 21)
More Posts:
- Move from Zsh to Bash shell macOS - MacOS
- Bash Command to Check Python Version - Bash
- error CAML Query containing special characters - SharePoint
- How to run Python file from Mac Terminal - Python
- How to Save file with .csv Extension using Notepad++ - NotepadPlusPlus
- Bash Command To Get Current Time - Bash
- Java: List of Data Structures available - Java
- How to get current URL Location using Javascript HTML - JavaScript