1 import java.util.Arrays;
2 import java.util.List;
3
4 /**
5 * 3种类加载器的加载目录
6 * @ author:xxx
7 * @ date:2020/8/2 00:05
8 */
9 public class TargetForClassLoader {
10
11 public static void main(String[] args) {
12 bootstrapClassLoader();
13 // extClassLoader();
14 // appClassLoader();
15 }·
16
17 /**
18 * 启动类加载器的职责
19 */
20 public static void bootstrapClassLoader() {
21 String property = System.getProperty("sun.boot.class.path");
22 List<String> list = Arrays.asList(property.split(";"));
23 list.forEach((t) -> {
24 System.out.println("启动类加载器目录:" + t);
25 });
26 }
27
28
29 /**
30 * 扩展类加载器
31 */
32 public static void extClassLoader() {
33 String property = System.getProperty("java.ext.dirs");
34 List<String> list = Arrays.asList(property.split(";"));
35 list.forEach((t) -> {
36 System.out.println("扩展类加载器" + t);
37 });
38 }
39
40 /**
41 * app 类加载器
42 */
43 public static void appClassLoader() {
44 String property = System.getProperty("java.class.path");
45 List<String> list = Arrays.asList(property.split(";"));
46 list.forEach((t) -> {
47 System.out.println("应用类加载器" + t);
48 });
49 }
50 }