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

Technical Problem:

Does your MPS-based application deliver a meaningless Java JNI exception without any other problems during the build process or during compilation time if functionalities of external JAR files are executed?


The reason for these JNI-Exceptions could be the use of so-called Multi-Release JAR files. These are JAR archives that contain class files of different Bytecode-Versions, which are either generated with different Java compilers or with different Java compatibility settings.

 To verify this, unpack the responsible JAR archive  and check the version of the class files. This is possible on the Windows platform using the following command:

javap.exe -v %PATH_TO_CLASS_FILE%/%CLASS_NAME%.class | findstr major

If you see different Major-Versions of the included class files here, this could be a cause of the JNI-Exception when running in MPS.

Try to compile the external JAR file directly from the source code, including all dependent libraries, also with the correct settings, for example by setting the command line parameters -source and -target to the same value (or -release, depending on the Java Version):

javac.exe -source 1.8 -target 1.8 %PATH_TO_JAVA_FILES%

In this example, it means that all class files are generated with Bytecode-Version 52. If all class files contained in the JAR archive have the same major version, experience has shown that execution in MPS is also possible without any problems.

Problems with JAR Integration in MPS