# java.lang.UnsupportedClassVersionError: org/example/MyClass 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

- **ID:** `java/unsupported-major-minor-version`
- **Domain:** java
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The compiled class file has a major version (e.g., 61 for Java 17) higher than what the running JVM supports (e.g., 52 for Java 8), indicating a mismatch between compile-time and runtime Java versions.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Java 8 (class version 52.0) | active | — | — |
| Java 11 (class version 55.0) | active | — | — |
| Java 17 (class version 61.0) | active | — | — |
| Java 21 (class version 65.0) | active | — | — |

## Workarounds

1. **Upgrade the runtime JVM to match the compilation version. For example, if class version is 61.0, run with Java 17 or later. Set JAVA_HOME and update PATH accordingly.** (95% success)
   ```
   Upgrade the runtime JVM to match the compilation version. For example, if class version is 61.0, run with Java 17 or later. Set JAVA_HOME and update PATH accordingly.
   ```
2. **Recompile the source code with a lower target version using javac -source 8 -target 8 (or --release 8) if the source is available.** (90% success)
   ```
   Recompile the source code with a lower target version using javac -source 8 -target 8 (or --release 8) if the source is available.
   ```
3. **Use a dependency management tool like Maven to enforce a consistent Java version across modules by setting <maven.compiler.source> and <maven.compiler.target> properties.** (85% success)
   ```
   Use a dependency management tool like Maven to enforce a consistent Java version across modules by setting <maven.compiler.source> and <maven.compiler.target> properties.
   ```

## Dead Ends

- **Set JAVA_HOME to an older JDK version and recompile** — This downgrades the runtime but the compiled classes still have the higher version; the error occurs at runtime, not compile time. (80% fail)
- **Add --release flag to the compiler without changing the JDK** — The --release flag only works if the correct JDK version is used; using it with an older JDK may still produce incompatible class files. (70% fail)
- **Delete the JAR file and rebuild with same JDK** — If the build environment hasn't changed, the same version mismatch will persist. (90% fail)
