简体   繁体   English

以下脚本中的javac命令行标志CLASSPATH和-d如何工作?

[英]How do the javac command line flags CLASSPATH and -d work in the script below?

Can anybody tell me the meaning of the batch file code below? 有人可以告诉我下面批处理文件代码的含义吗? I know the meaning of the first line as it sets the path to current Framework directory but I need the meaning of second and third line. 我知道第一行的含义,因为它设置了当前Framework目录的路径,但是我需要第二行和第三行的含义。

cd /d %~dp0Framework cd / d%〜dp0框架
SET CLASSPATH=..\\Framework*;..\\Framework.;..\\Framework\\lib*; SET CLASSPATH = .. \\ Framework *; .. \\ Framework。; .. \\ Framework \\ lib *;
javac -d . javac -d。 *.java *的.java
pause 暂停

In the Second Line you are setting the path of your class File. 在第二行中,您将设置类File的路径。 While in the third line you are using the JDK provided javac(java Compiler) to compile your java file in class files. 在第三行中,您正在使用JDK提供的javac(java Compiler)在类文件中编译Java文件。 which can be run by the jre the -d option tells javac the existing directory where class files should be generated . 可以通过jre运行-d选项告诉javac应该在其中生成类文件的现有目录。 But javac -d . *.java 但是javac -d . *.java javac -d . *.java will give that it is not the correct way to use javac javac -d . *.java会指出这不是使用javac的正确方法

The line 线

SET CLASSPATH=..\\Framework*;..\\Framework.;..\\Framework\\lib*; SET CLASSPATH = .. \\ Framework *; .. \\ Framework。; .. \\ Framework \\ lib *;

tells javac where to find the classes you need (depend on) 告诉javac在哪里找到需要的类(取决于)

The -d . -d . sets the destination directory for compiled classes to the current directory . 将已编译类的目标目录设置为当前目录 Please note that there is a . 请注意有一个. after -d . -d之后。 A . . on command line means current directory (or what is called working directory in DOS). 在命令行上表示当前目录(或在DOS中称为工作目录)。 If you put in say -dc:\\tmp (you might have to try c:\\\\tmp - I am not too familiar with DOS) and you actually have such a directory, the output will go there. 如果输入-dc:\\tmp (您可能必须尝试使用c:\\\\tmp我对DOS不太熟悉)并且您实际上有这样的目录,则输出将进入该目录。

Hope that helps. 希望能有所帮助。

I think the batch file is broken. 我认为该批处理文件已损坏。 The second line uses an undocumented way of specifying a wildcard that immediately follows a name ( ..\\Framework* ). 第二行使用未记录的方式来指定紧随名称( ..\\Framework* )之后的通配符。 See https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html#A1100762 for the legal ways of specifying a wildcard. 有关指定通配符的合法方法,请参见https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html#A1100762 Perhaps it should be ..\\Framework\\* ? 也许应该是..\\Framework\\*吗? As for the third line, the option -d . 至于第三行,选项-d . does nothing, because the current directory would be used by default if that option was not there. 什么都不做,因为如果没有该选项,默认情况下将使用当前目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM