Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
11.3
-
None
-
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.3Product 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
Description
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:
static boolean isModifiable(char c) { boolean canModify = switch (c) { case 'ñ', 'Ñ' -> false; default -> true; }; return canModify; }
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:
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)
When I build the project the message is logged
To run this application from the command line without Ant, try: java -jar "D:\NB113\Diacritics\dist\Diacritics.jar"
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:
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.