Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

java - 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?

Isn't the current path always in ClassPath by default, and thus no need to explicitly specify?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From Oracle's page on setting the class path:

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.

Use ; for Windows and : for Unix-like operating systems as a separator for multiple paths.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...