# java.net.URLClassLoader.addURL 错误

**URL:** <https://www.isharkfly.com/t/java-net-urlclassloader-addurl/15692>\
**Category:** 程序语言\
**Tags:** java, maven\
**Created:** [April 30, 2024, 8:55pm UTC](https://www.isharkfly.com/t/java-net-urlclassloader-addurl/15692 "2024-04-30T20:55:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [April 30, 2024, 8:55pm UTC](https://www.isharkfly.com/t/java-net-urlclassloader-addurl/15692/1 "2024-04-30T20:55:31Z")

</div>

在 activejdbc 项目编译的时候提示错误：

```auto
[ERROR] Failed to execute goal org.javalite:activejdbc-instrumentation:2.0:instrument (default) on project activejdbc: Failed to add output directory to classpath: Unable to make protected void java.net.URLClassLoader.addURL(java.net.URL) accessible: module java.base does not "opens java.net" to unnamed module @9175580c -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :activejdbc

```

 ![2024-04-30_16-53-29](https://cdn.isharkfly.com/com-isharkfly-www/discourse-uploads/original/2X/7/7a195c8ce47d13351a060bd1299ac9cb6390d0cb.png)

上面的错误是什么问题？

## 错误原因和解决

出现上面的错误原因是 activejdbc 版本和 JDK 的版本不一致导致的。

activejdbc 我们还用在 `<activejdbc.version>2.0</activejdbc.version>` 版本，但 JDK 已经是 17 的版本了。

为了解决这个问题，activejdbc 的版本需要修改为： `3.4-j11` 这个版本才能用 JDK 17 进行编译。
