# java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher 由较新版本的 Java 运行时编译（类文件版本 61.0），此 Java 运行时仅识别最高版本 55.0 的类文件

- **ID:** `cicd/jenkins-agent-java-version-mismatch`
- **领域:** cicd
- **类别:** runtime_error
- **错误码:** `JENKINS_JAVA_VERSION`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

Jenkins agent 运行较旧版本的 Java（例如 Java 11），而 Jenkins 控制器运行较新版本（例如 Java 17），导致 remoting jar 不兼容。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Jenkins 2.440 | active | — | — |
| Jenkins 2.450 | active | — | — |
| Java 11 | active | — | — |
| Java 17 | active | — | — |
| Java 21 | active | — | — |

## 解决方案

1. ```
   On the Jenkins agent, install Java 17 or later matching the controller's version. Update JAVA_HOME and restart the agent service. For Linux: sudo apt install openjdk-17-jre && sudo systemctl restart jenkins-agent
   ```
2. ```
   Use the 'WebSocket' agent connection mode instead of TCP: In Jenkins controller, configure the agent to use WebSocket (under Advanced > WebSocket). This bypasses some class version checks.
   ```

## 无效尝试

- **** — Updating the agent.jar file manually without updating the Java runtime still fails because the agent JVM is too old. (80% 失败率)
- **** — Setting JAVA_HOME on the agent to a Java 8 installation makes the error worse as the version gap increases. (90% 失败率)
- **** — Restarting the Jenkins controller does not affect agent Java versions; the agent must be upgraded independently. (70% 失败率)
