JAVA JNI Error during MPS 2020.1 Migration

Technical Problem:

Are you trying to migrate your application based on the MPS framework from MPS 2019.3 to MPS 2020.1, the build process works fine, only when you start the generated application do you get a pop-up window regarding a Java JNI-Exception?


First, start the application directly from the command line. Now you can see the concrete stack trace of the returned exception:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: 
jetbrains/mps/Launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Here you can see that the application is started with an outdated Java JRE version (in this case Java 1.8). The cause for the error is therefore to be found within the batch files that were created by the MPS build scripts. A comparison with MPS 2019.3 shows that the previously expected path to the JRE has changed.

The previous storage location "jre" or "jre64" is now "jbr" or "jbr-x86" with MPS 2020.1. If this directory does not exist, the JRE version found on the system according to JAVA_HOME is used.

11, this UnsupportedClassVersionError is the result. A simple renaming of the "jre" directory to "jbr" completely solves this problem after a new build process.

Java JNI-Exception External JAR-File in MPS Based Application