Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/398.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java目录结构_Java - Fatal编程技术网

Java目录结构

Java目录结构,java,Java,给定以下目录结构: bigProject |--source | |--Utils.java | |--classes |-- 以及以下命令行调用: javac-d类源代码/Utils.java 假设当前目录是bigProject,结果是什么 A. If the compile is successful, Utils.class is added to the source directory. B. The compiler returns an invalid flag error. C

给定以下目录结构:

bigProject
|--source
| |--Utils.java
|
|--classes
|--
以及以下命令行调用: javac-d类源代码/Utils.java 假设当前目录是bigProject,结果是什么

A. If the compile is successful, Utils.class is added to the source directory.
B. The compiler returns an invalid flag error.
C. If the compile is successful, Utils.class is added to the classes directory.
D. If the compile is successful, Utils.class is added to the bigProject directory.
答:C

谁能解释一下,为什么答案是C。

-d classes命令行开关告诉编译器将编译后的代码存储在classes文件夹中

参见javac的示例:

-d目录

设置类文件的目标目录。目标目录必须已经存在;javac不会创建 目标目录。如果类是包的一部分,javac将 子目录中反映包名称的类文件,创建 根据需要设置目录。例如,如果指定-d/home/myclasses 类名为com.mypackage.MyClass,则类文件为 调用/home/myclasses/com/mypackage/MyClass.class

如果-d不是 指定后,javac将类文件放在与 源文件

如果在没有任何参数的情况下运行javac,则会打印帮助内容

Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
和-d表示-d指定放置生成的类文件的位置