You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 07:20:04