简体   繁体   中英

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.

cd /d %~dp0Framework
SET CLASSPATH=..\\Framework*;..\\Framework.;..\\Framework\\lib*;
javac -d . *.java
pause

In the Second Line you are setting the path of your class File. While in the third line you are using the JDK provided javac(java Compiler) to compile your java file in class files. which can be run by the jre the -d option tells javac the existing directory where class files should be generated . But javac -d . *.java javac -d . *.java will give that it is not the correct way to use javac

The line

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

tells javac where to find the classes you need (depend on)

The -d . sets the destination directory for compiled classes to the current directory . Please note that there is a . after -d . A . on command line means current directory (or what is called working directory in 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.

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* ). See https://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html#A1100762 for the legal ways of specifying a wildcard. Perhaps it should be ..\\Framework\\* ? As for the third line, the option -d . does nothing, because the current directory would be used by default if that option was not there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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