UnsupportedClassVersionError when running an application

Hello MicroEJ ,

I have a problem running a build-microej-javalib module on a simulator. It’s a one year old benchmark that generates performance tests with JUnit.
I have an UnsupportedClassVersionError visible below :

Cannot find main class com/microej/ui/test/_AllTests_MyTests
Exception in thread "Exception in thread <noname> (id=255): java.lang.ExceptionInInitializerError: java.lang.NullPointerException
	at java.lang.Throwable.fillInStackTrace(Throwable.java:82)
	at java.lang.Throwable.<init>(Throwable.java:32)
	at java.lang.Exception.<init>(Exception.java:14)
	at java.lang.RuntimeException.<init>(RuntimeException.java:14)
	at java.lang.NullPointerException.<init>(NullPointerException.java:6)
	at java.lang.System.buildOutputStream(System.java:239)
	at java.lang.System.<clinit>(System.java:51)
	at java.lang.Throwable.fillInStackTrace(Throwable.java:82)
	at java.lang.Throwable.<init>(Throwable.java:37)
	at java.lang.Error.<init>(Error.java:18)
	at java.lang.LinkageError.<init>(LinkageError.java:18)
	at java.lang.ClassFormatError.<init>(ClassFormatError.java:10)
	at java.lang.UnsupportedClassVersionError.<init>(UnsupportedClassVersionError.java:10)

For the moment, this project is on SDK 5 (23.07) using jdk-11.0.16.1+1.
I’ve tried the following actions:

  • update buildtype to module="build-microej-javalib" revision="6.2.+"
  • update JUnit dependency to org="ej.library.test" name="junit" rev="1.7.1"

Do you know what could be the issue?

Thanks,
S.

1 Like

Hi Sarah,

The error UnsupportedClassVersionError may indicate that you use the wrong version of the Java compiler for your application.

Please check if your Java Compiler uses the version 1.7 by clicking on Window > Preferences > Java > Compiler > JDK Compliance > Compiler Compliance level.

Below is the configuration window to configure this parameter:

Sometimes when the JDK is updated to version 11, the Compiler compliance level is updated too which generates the error you experience.

Please let us know if this message solves your issue.

Best regards,
Erwan

1 Like

Hi Erwan,

You were right, the Compiler Compliance level was set to 11 instead of 1.7.
I retried the execution with this update and it works now.

Thanks for your help,
S.

1 Like

Hi Sarah,

Thanks for your feedback.

For more information about which version of Java is supported by MicroEJ, please read this documentation section MicroEJ Runtime — MicroEJ Documentation

Note that you can upload in your project the .settings/ folder which contains the file org.eclipse.jdt.core.prefs, in order to avoid this issue for next developers of your project.

Best regards,
Erwan