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很少指定的原因

 

 

 

 

 

 

 

posted @ 2022-04-12 14:57  ascertain  阅读(62)  评论(0编辑  收藏  举报