redskap / swagger-brake

Swagger contract checker for breaking API changes
Apache License 2.0
57 stars 16 forks source link

UnsupportedClassVersionError: SwaggerBrakeMain has been compiled by a more recent version #121

Closed fairking closed 1 month ago

fairking commented 7 months ago

I could not execute the recent version of swagger-brake-2.4.0-cli.jar on windows. I tried to go to https://www.java.com/download/ie_manual.jsp and download and install the recent Java runtime, but the error persists. Tried to restart the PC. No chance.

I am running the following command:

java -jar "..\..\Utils\SwaggerBrake\swagger-brake-2.3.0-cli.jar" --old-api=schema_old_live.json --new-api=schema.json --output-formats=HTML --output-path=.\

Exception in thread "main" java.lang.UnsupportedClassVersionError: io/redskap/swagger/brake/cli/SwaggerBrakeMain 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 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

My java version is:

C:\Users\Admin>java -version
java version "1.8.0_391"
Java(TM) SE Runtime Environment (build 1.8.0_391-b13)
Java HotSpot(TM) Client VM (build 25.391-b13, mixed mode, sharing)

C:\Users\Admin>

image

Is there anything else needs to be done in order to fix it?

galovics commented 7 months ago

hi @fairking.

There's been an upgrade from JDK8 to JDK17 recently. Please give it a try with that.

fairking commented 7 months ago

hi @fairking.

There's been an upgrade from JDK8 to JDK17 recently. Please give it a try with that.

Ok, thanks for the reply. Looks like it's a separate Dev Kit, not a runtime. And it's proprietary software. I don't think I am going to use it. (https://www.oracle.com/java/technologies/downloads/#jdk17-windows). Things become over-complicated.

galovics commented 7 months ago

@fairking

Using newer Oracle JDKs could be a pain in the butt for sure with the changed licensing structure.

I'd say you should use either OpenJDK distributions or go straight with Amazon Corretto. I mostly use the latter.