Java: sourcepath classpath
classpath:
import java.io.File; import java.util.Arrays; public class B { public static final void main(String[] args) { String property = System.getProperty("java.class.path"); String[] splits = property.split(File.pathSeparator); Arrays.sort(splits); for (String split : splits) { System.out.println("classpath = " + split); } } }
javac 编译时可指定-cp 和 -sourcepath
java 只能指定-cp
If the -sourcepath option is not specified, the user class path is searched for source files as well as class files
如果没有指定-sourcepath, classpath会被用来寻找源码和class文件, 这就是sourcepath很少指定的原因