默认情况下,类路径中的当前路径是`.`吗? [英] Is the current path `.` in the classpath by default?
问题描述
第二个命令是否将当前路径添加为另一个搜索路径?
Do the second command add the current path as another path for searching?
javac -cp /home/tim/program_files/programming/java/junit-4.11.jar MyTest.java
javac -cp .:/home/tim/program_files/programming/java/junit-4.11.jar MyTest.java
这是用冒号分隔多个路径的正确方法吗?
Is it the correct way to separate multiple paths, by a colon?
默认情况下当前路径不总是在ClassPath中,因此不需要显式指定吗?
Isn't the current path always in ClassPath by default, and thus no need to explicitly specify?
谢谢。
推荐答案
来自Oracle的页面:
默认的类路径是当前目录。设置CLASSPATH变量或使用-classpath命令行选项会覆盖该缺省值,因此如果要在搜索路径中包含当前目录,则必须包含。。在新设置中。
The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.
对Windows使用;
和:
用于类Unix操作系统,作为多路径的分隔符。
Use ;
for Windows and :
for Unix-like operating systems as separator for multiple paths.
这篇关于默认情况下,类路径中的当前路径是`.`吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!