Java:新手“javac:无效标志”编译错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12181329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:54:25  来源:igfitidea点击:

Java: newbie "javac: invalid flag" compile error

java

提问by ggkmath

I'm trying to compile a Java 1.6 program. The following compiles without error:

我正在尝试编译 Java 1.6 程序。以下编译没有错误:

# javac -cp /path/to/ojdbc6.jar:. MyJavaProgram.java

But adding a flag causes this error:

但是添加标志会导致此错误:

# javac -cp /path/to/ojdbc6.jar:. -Doracle.jdbc.SetFloatAndDoubleUseBinary=true MyJavaProgram.java -help
javac: invalid flag: -Doracle.jdbc.SetFloatAndDoubleUseBinary=true
Usage: javac <options> <source files>
use -help for a list of possible options

Is the flag not supported? I added the -helpbut it didn't give any more info (did I add it in the right place above?).

不支持标志?我添加了-help但它没有提供更多信息(我是否在上面的正确位置添加了它?)。

回答by hmjd

The options must come before the source files (as indicated in your question): remove the -help.

选项必须在源文件之前(如您的问题所示):删除-help.

-Doption specify properties and are passed to the JVM (java) and are not compile time flags. From java -help:

-D选项指定属性并传递给 JVM ( java) 并且不是编译时标志。来自java -help

-D<name>=<value>
       set a system property

To view the list of available compiler options execute:

要查看可用编译器选项的列表,请执行:

javac -help

javac -help