I'd like to try out the jdk21 string template feature. I've downloaded the java 21 jdk and set up a project in intellij using that. It doesn't accept the string template code as valid. Also using javac on the command line also fails to compile the code. Here's the command line:
'E:\development\java\jdk21\jdk-21\bin\javac.exe' .\src\Main.java --enable-preview --release 21
And here's the compiler error:
.\src\Main.java:4: error: illegal escape character
String info = STR."My name is \{name}";
Any ideas how to make this work? (preferably in intellij but CLI is ok)
#jdk21 / Intellij
6 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @dry folio! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
it should be String info = STR."My name is \{name}";
slash right before {
I did have a slash there - it disappeared in my post (since edited). The code was copied from the JEP description so it should be correct.