java.lang.UnsupportedClassVersionError when trying to run a Java scratch.

Answered

When try to run a scratch with the following code:

class Scratch {
public static void main(String[] args) {
System.out.println("Helllo world");
}
}

I get the following output in the console.

Error: LinkageError occurred while loading main class Scratch
java.lang.UnsupportedClassVersionError: Preview features are not enabled for Scratch (class file version 55.65535). Try running with '--enable-preview'

Process finished with exit code 1

Any idea how to solve this?

 

 

 

5
2 comments

Please try switching to JDK10

-3

Seems to be some kind of misconfiguration.

- the compilation was invoked with


$JDK11/bin/javac --enable-preview --release 11 Scratch.java


- then the execution must be

$JDK11/bin/java --enable-preview Scratch


- if you call it only as

$JDK11/bin/java Scratch

then you get

java.lang.UnsupportedClassVersionError: Preview features are not enabled for Scratch (class file version 55.65535). Try running with '--enable-preview'

For me the preview feature (JEP 12 http://openjdk.java.net/jeps/12 ) is working as intended. Check in your settings where you specify the option `--enable-preview` for the compilation.

0

Please sign in to leave a comment.