java.lang.UnsupportedClassVersionError
I am attempting to build a language plugin for my DSL. This normally works but has stopped working and I cannot fix it.
java.lang.UnsupportedClassVersionError: EditLangV2/structure/StructureAspectDescriptor has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
I have tried every way I know of to set the Java version but this error always occurs when I install it.
Any help would be much appreciated.
Please sign in to leave a comment.
Hi! Did I get you correctly you is able to build the plugin, but the problem happens when you install the plugin in MPS?
What happened before you run into this problem? Maybe you updated MPS version?
Yes, the build works without error and generates the zip as normal (I'm running on Windows 10 and MPS 2021.3.1). When I install the plugin and open a solution that uses the previous version of the plugin, none of my objects are recognized and MPS shows the error from my original post.
Prior to this error occurring, I was attempting to generate a standalone IDE from MPS where the instructions talk about copying the output of that process to a bin folder in the MPS directory.
I have since uninstalled MPS and reinstalled just in case I messed something up (I manually deleted any remaining files in Program Files and AppData). I have also looked through my system variables and PATH for references to other versions of the JDK but have not found any. I don't have JAVA_HOME defined for example and my PATH variable contains nothing that is obviously JDK related.
Just some additional information. If I open the project where I develop the langauge in one MPS window and open the other project where the business uses the langauge in another, both work without issue. So something with how MPS build the language in development mode is working fine but my build process is wrong.
MPS 2021.3.1 has java 11 version as it's runtime (class file version 55.0). And the error message confirms this ("his version of the Java Runtime only recognizes class file versions up to 55.0"). So somehow you compiled your plugin with java 17 (class file version 61.0).
My first idea was that you tried MPS 2022.2 (it has java 17 as it's runtime) and build the plugin with MPS 2022.2.
Anyway if you run a build script in MPS then the first line in the opened Run toolwindow will show the actual java that used.
When I run my build script, this is the output. I have not modified this at all.
C:\Program Files\JetBrains\MPS 2021.3\jbr\bin\java.exe -jar C:\Users\MATTHE~1\AppData\Local\Temp\jmb17177905491359807225.jar -Djava.home=C:\Program Files\JetBrains\MPS 2021.3\jbr -Dant.home=C:\Program Files\JetBrains\MPS 2021.3\lib\ant -Dmps_home=C:\Program Files\JetBrains\MPS 2021.3 -f C:\source\EditLanguage\build.xml
Buildfile: C:\source\EditLanguage\build.xml
Trying to override old definition of datatype module
fetchDependencies:
java.compile.EditLangV2:
java.compile.EditLangV2.generator:
compileJava:
processResources:
classes:
declare-mps-tasks:
assemble:
[jar] Building jar: C:\source\EditLanguage\build\tmp\EditDSLv2\default\EditDSLv2.zip\EditDSLv2\lib\EditDSLv2.jar
[jar] Building jar: C:\source\EditLanguage\build\tmp\EditDSLv2\default\EditDSLv2.zip\EditDSLv2\languages\EditDSLv2\EditLangV2.jar
[jar] Building jar: C:\source\EditLanguage\build\tmp\EditDSLv2\default\EditDSLv2.zip\EditDSLv2\languages\EditDSLv2\EditLangV2-generator.jar
[zip] Building zip: C:\source\EditLanguage\build\artifacts\EditDSLv2\EditDSLv2.zip
build:
BUILD SUCCESSFUL
Total time: 1 second
Process finished with exit code 0
Out of this log I see java classes are not compiled, some old compilation artifacts are taken. So you can either delete temporary build files manually or to add "clean assemble build" (I'm not quite sure here about last 2 options) ant options in the run configuration of the build project.