Ubuntu 22.04下NetBeans构建失败(提示release版本17不支持)
构建NetBeans时"release version 17 not supported"错误的解决办法
环境配置
- Java版本:17.0.6
- Ant版本:1.10.12
- 操作系统:Ubuntu 22.04.4 LTS
问题现象
构建NetBeans过程中失败,报错日志如下:
-do-compile: [nb-javac] Compiling 10 source files to /media/meca1/GITHUB-NETBEANS/netbeans/platform/api.dashboard/build/classes [nb-javac] Ignoring source, target and bootclasspath as release has been set [repeat] error: release version 17 not supported [repeat] Usage: javac <options> <source files> [repeat] use --help for a list of possible options [nbmerge] Failed to build target: all-api.dashboard BUILD FAILED /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:635: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:630: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:665: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:648: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:630: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/build.xml:677: The following error occurred while executing this line: /media/meca1/GITHUB-NETBEANS/netbeans/nbbuild/templates/common.xml:208: Compile failed; see the compiler error output for details
已尝试操作
- 首次使用JDK 17构建失败
- 执行
export JAVA_HOME=/opt/jdk-11切换到JDK 11,问题依旧(NetBeans官方文档显示JDK 17兼容)
解决办法
- 确认Ant使用的JDK版本:执行
ant -version,查看输出中的Java版本,确认Ant是否读取到了正确的JDK。 - 刷新环境变量:切换JAVA_HOME后,执行
source ~/.bashrc(bash终端)或source ~/.zshrc(zsh终端),或直接重启终端,确保环境变量生效。 - 检查NetBeans构建配置:打开
nbbuild/build.properties文件,找到jdk.home配置项,将其设置为正确的JDK 17路径(例如jdk.home=/opt/jdk-17.0.6),覆盖系统环境变量的设置。 - 清理构建缓存:执行
ant clean命令清理之前的构建残留,然后重新执行构建命令。 - 验证JDK有效性:执行
javac -version和java -version,确认输出为17.0.6,确保JDK安装完整且未损坏。
内容的提问来源于stack exchange,提问作者user11164708
相关产品推荐
相关产品推荐

