"Unsupported major.minor version 52.0" in Java 7

Issue #443 resolved
Former user created an issue

Nimbus JOSE + JWT is specified to work with Java 7.

https://connect2id.com/products/nimbus-jose-jwt#maven

For Java 7+ check out the latest release:

However, at runtime I get an UnsupportedClassVersionError and the application exits.

public class App {
    public static void main(String[] args) throws ParseException {
        JWTParser.parse("eyJhbGciOiJub25lIn0.eyJleHAiOjE2MzE2NzA5NzgxMTQsInN1YiI6Ijk5OTktOTk5OSIsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6NzAwMCIsIm5iZiI6MTYzMTY2OTc3ODExNCwicmFuZG9tIjoiYmU4Y2Y3ODU0ZjljMTVkNjNmZGFlZDhhYTlmODcxNWI2NzVhYzZhYjAxZGRkODc5Y2U0NmQ5MThhMWUzYmRiZSJ9.");
    }
}
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/nimbusds/jose/shaded/json/parser/ParseException : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:808)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:443)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:65)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:349)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:348)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:430)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:329)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
        at com.nimbusds.jwt.JWTParser.parse(JWTParser.java:67)
        at jwtapp.App.main(App.java:9)

The reason is that json-smart@2.x doesn't support Java 7.

json-smart@1.x supports Java 7 and is still maintained. The Nimbus OAuth 2.0 SDK pom.xml states that json-smart works with both 1.x and 2.x.

        <dependency>
            <groupId>net.minidev</groupId>
            <artifactId>json-smart</artifactId>
            <version>[1.3.3,2.4.7]</version>
        </dependency>

Could Nimbus JOSE + JWT also support both like the Nimbus OAuth 2.0 SDK?

Comments (4)

  1. Philippe GRANET

    Same problem for me:

    Servlet failed with Exception
    java.lang.UnsupportedClassVersionError: com/nimbusds/jose/shaded/json/parser/ParseException : Unsupported major.minor version 52.0
    

  2. Rubén Luna Account Deactivated

    You have to find a version of Nimbus JOSE + JWT that works for Java 7. The error is because you are trying to compile in Java 7 the Nimbus JOSE + JWT library that is in Java 8 (hence the error 52)

  3. Vladimir Dzhuvinov

    Check out version 9.24.1 (2022-08-16) or later.

    The JSON Smart dependency switched to Java 8 without announcement and this caused (9.9,9.24.1] until now to break the Java 7 min requirement.

  4. Log in to comment