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:
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated - Java
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error - Git
- How to update Python Version on Mac (macOS) - MacOS
- [Android] Sharing Multiple Images to Twitter App from your App - Twitter
- Android : Prevent App for rotation landscape or portrait - Android
- How to know my IP on Mac Ventura 13.0 - MacOS
- How to Enable Dark Mode Theme in Microsoft Teams - Teams
- CentOS Cannot find a valid baseurl for repo base7x86_64 yum - HowTos