2014-10-07 74 views
2

第二個命令是否將當前路徑添加爲另一個搜索路徑?默認情況下,classpath中的當前路徑是否是「。」?

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 

這是通過冒號分隔多個路徑的正確方法嗎?

默認情況下不是當前路徑總是在ClassPath中,因此不需要顯式指定?

謝謝。

回答

2

從甲骨文上設置類路徑的page

缺省類路徑是當前目錄。設置CLASSPATH變量或使用-classpath命令行選項將覆蓋該默認值,因此如果要將當前目錄包含在搜索路徑中,則必須包含「。」。在新的設置中。

對於Windows使用;,對於類Unix操作系統使用:作爲多路徑分隔符。

1

第二個命令是否將當前路徑添加爲另一個搜索路徑?

它是由一個冒號分隔多個路徑,正確的方法是什麼?

依賴於平臺,在UNIX平臺上:作品,在Windows中,您需要;

默認情況下是不是當前路徑總是在類路徑中,因此,無需顯式地指定?

當前目錄是默認存在,除非你在第一種情況下-cp覆蓋它,它沒有出現在第二種情況下它是

1

the help page (FOR WINDOWS)

-classpath classpath 
-cp classpath 

    Specifies a list of directories, JAR files, and ZIP archives to 
    search for class files. Separate class path entries with semicolons 
    (;). Specifying -classpath or -cp overrides any setting of the 
    CLASSPATH environment variable. 

    If -classpath and -cp are not used and CLASSPATH is not set, then the 
    user class path consists of the current directory (.). 

注意,在窗口上,路徑分隔符是;分號。

在其他平臺上,分隔符是冒號:

這符合各種平臺上的標準路徑系統。

相關問題