奇思妙想 · 2024年 5月 29日 0

Java -source 1.6参数提示"警告: [options] 未与 -source 1.6 一起设置引导类路径"

88 次浏览

因为是使用Java 1.6的源代码设置,但是没有为编译器指定正确的引导类路径(bootstrap classpath),这会让Java编译器感到困惑,如果当前JDK是1.8, 但又想让用1.6版本编译,可能会出现错误。必须在命令行中加入boot class path:

  • JDK8 and before: -bootclasspath /path/to/jdk1.6/jre/lib/rt.jar
  • JDK9 and later: --module-path /path/to/module_path