Rick Hegarty created NETBEANS-4049: -------------------------------------- Summary: UnsupportedClassVersionError when running JDK14 code with --enable-preview Key: NETBEANS-4049 URL: https://issues.apache.org/jira/browse/NETBEANS-4049 Project: NetBeans Issue Type: Bug Components: platform - Execution, platform - Options&Settings Affects Versions: 11.3 Environment: Product Version: Apache NetBeans IDE 11.3 Java: 14; OpenJDK 64-Bit Server VM 14+36-1461 Runtime: OpenJDK Runtime Environment 14+36-1461 System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb) User directory: C:\Users\johndoe\AppData\Roaming\NetBeans\11.3 Cache directory: C:\Users\johndoe\AppData\Local\NetBeans\Cache\11.3 Reporter: Rick Hegarty Attachments: nb113enablePreview.png
I have installed NB 11.3 on Windows 10, with JDK 14 as its only Java platform. I created a simple _Java with Ant_ project, and wrote code using "arrow case" labels in a switch block: {code:java} static boolean isModifiable(char c) { boolean canModify = switch (c) { case 'ñ', 'Ñ' -> false; default -> true; }; return canModify; } {code} NetBeans detected that this was a JEP 354 preview feature, and set *--enable-preview* for compilation (_Properties > Build > Compiling > Additional Compiler Options_) and execution (_Properties > Run > VM Options_). The code compiled with no problems, but running it (_Run > Run Project_) resulted in this error: {code:java} run: Error: LinkageError occurred while loading main class com.Diacritics java.lang.UnsupportedClassVersionError: com/Diacritics (class file version 57.65535) was compiled with preview features that are unsupported. This version of the Java Runtime only recognizes preview features for class file version 58.65535 C:\Users\johndoe\AppData\Local\NetBeans\Cache\11.3\executor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\johndoe\AppData\Local\NetBeans\Cache\11.3\executor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds) {code} When I build the project the message is logged {code:java} To run this application from the command line without Ant, try: java -jar "D:\NB113\Diacritics\dist\Diacritics.jar"{code} If I run from the command line with JDK 14 on the *PATH*, using what NetBeans proposes (i.e. *java -jar "D:\NB113\Diacritics\dist\Diacritics.jar"*) I also get the linkage error described above. However, when I added the *--enable-preview* option to the command line call it works fine, as shown in this screen shot: !nb113enablePreview.png! This suggests that when running the project within NetBeans the _VM Option_ *--enable-preview* is being ignored. There is no issue when creating a Java application using _Java with Maven_ that contains the same code. This is only an issue for _Java with Ant_ projects. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists