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.
![21 (Preview) - String templates, unnamed classes and instance main methods etc 21 (Preview) - String templates, unnamed classes and instance main methods etc](https://code2care.org/java-jdk-21/enable-java-jdk-21-preview-features-on-intellij/images/21 (Preview) - String templates, unnamed classes and instance main methods etc.jpg)
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:
- Android Emulator 5.1.1 not loading on Mac OS X Android Studio - Android-Studio
- Fix: error: unclosed character literal in Java - Java
- AWS SNS CLI Command Publish Message Attributes - AWS
- Fix: MySQL: ERROR 1044 (42000): Access denied for user @localhost to database - MySQL
- jQuery : Move to top of the page - jQuery
- Reopen previously closed tab in Google Chrome - Chrome
- How to check Command Line Tools Version [Updated for Ventura] - MacOS
- When should we use Primitive or Wrapper types in Java? - Java