Resolving java.lang.UnsupportedClassVersionError in Custom SiteMinder Java Code
search cancel

Resolving java.lang.UnsupportedClassVersionError in Custom SiteMinder Java Code

book

Article ID: 440133

calendar_today

Updated On:

Products

SITEMINDER

Issue/Introduction

You receive a java.lang.UnsupportedClassVersionError or a "bad class file" error (e.g., class file has wrong version 61.0, should be 52.0) when you attempt to compile or run custom Java code that utilizes SiteMinder SDK libraries.

Environment

  • Product: SiteMinder
  • Component: SDK (Java)
  • Operating System: Linux/Windows

Cause

This issue is caused by a Java version mismatch between the JDK used to compile the code (or the compiled version of the provided JAR files) and the Java Runtime Environment (JRE) used to execute it. For example, a class file version of 61.0 corresponds to Java 17, while version 52.0 corresponds to Java 1.8. If you attempt to run code compiled for Java 17 on a Java 1.8 runtime, the JRE cannot recognize the newer class format.

Resolution

To resolve this issue, you must ensure that your compilation environment and runtime environment use matching Java versions.

  1. Identify the required version: Check the error message to see which version the class file requires (e.g., version 61.0 requires Java 17).
  2. Update the Runtime: Ensure the JRE you use to run the application is equal to or higher than the version used for compilation.
  3. Recompile the code: You can try compiling the code again with a matching version of the JDK as the runtime you will be using.
    • For example, if you must run on Java 1.8, you must compile using a JDK 1.8.
    • If you are using JARs that are already compiled for Java 17, you must upgrade your runtime to Java 17 or higher.
  4. Verify the Classpath: Ensure your compilation command explicitly points to the correct JDK and libraries:
    ####/java/bin/javac -classpath /opt/CA/siteminder/sdk/java/smjavasdk2.jar:####/your_custom_jar.jar -d /opt/samplecode YourCode