【问题标题】:Error while compiling with javac in Ubuntu在 Ubuntu 中使用 javac 编译时出错
【发布时间】:2019-10-13 10:41:07
【问题描述】:

我正在尝试在 Ubuntu 中编译一些软件来运行它。我下载了它,我看到有一个 compile.bat 文件。我试图用 Wine 运行它,但我得到了一些错误。之后,我使用与 compile.bat 文件相同的命令创建了一个 compile.sh 文件。这些命令是:

javac -extdirs lib/ core/*.java
javac -extdirs lib/ movement/*.java
javac -extdirs lib/ report/*.java
javac -extdirs lib/ routing/*.java
javac -extdirs lib/ gui/*.java
javac -extdirs lib/ input/*.java
javac -extdirs lib/ applications/*.java
javac -extdirs lib/ interfaces/*.java

我尝试运行 .sh 脚本,但出现此错误:

root@vbox:/media/sf_shared/one_1.4.1# ./compile.sh 
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11
error: option -extdirs not allowed with target 11

这些是我的 java 版本:

javac 11.0.4
/usr/bin/javac
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode, sharing)
/usr/bin/java

似乎“extdirs”选项不存在。但是,它被列为 javac 选项:

-extdirs <dirs>              Override location of installed extensions

root@vbox:/media/sf_shared/one_1.4.1# javac -extdirs
error: -extdirs requires an argument
Usage: javac <options> <source files>
use --help for a list of possible options

我该如何解决?任何帮助都会很有用,因为我对 Java 不太了解。

【问题讨论】:

  • 检查hereextdirs 只能在编译 JDK 9 之前的版本时使用。
  • 哦,我明白了.. 谢谢!你知道 JDK11 中 extdirs 的一些解决方法吗?
  • 我自己没试过,但也许 -cp 可以帮助你,因为有人建议 here ...
  • 好的,谢谢。我将我的默认 java 更改为 1.8 并且它工作。我也会试试你的解决方案。

标签: java ubuntu compilation javac


【解决方案1】:

改成java1.8解决了@seconf说的问题。

【讨论】:

    猜你喜欢
    • 2014-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-23
    • 1970-01-01
    相关资源
    最近更新 更多