# java.lang.ClassDefNotFoundException

- **ID:** `java/class-def-not-found-error`
- **领域:** java
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

JVM 无法找到编译时引用的类的定义，通常是由于类路径中缺少或不匹配的类文件，或构建产物不完整。

## 版本兼容性

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

## 解决方案

1. ```
   Run 'mvn clean install' or 'gradle clean build' to force a full rebuild and ensure all class files are generated correctly.
   ```
2. ```
   Check the classpath using 'java -verbose:class YourMainClass' to see which class files are loaded and identify the missing one.
   ```

## 无效尝试

- **** — This may include duplicate or conflicting versions of the same class, leading to other linkage errors, and does not address missing dependencies from transitive dependencies. (40% 失败率)
- **** — Stale class files from previous builds can mask the real issue; a clean build is necessary to ensure all classes are regenerated. (60% 失败率)
