Does system classloader load all classes in classpath even if they're not actually used?

前端 未结 3 1695
难免孤独
难免孤独 2021-01-22 13:57

I\'m using JDK 1.6 to run a small application. However I set a very massive classpath which includes a lot of classes.

When I run the application will all classes in the

3条回答
  •  借酒劲吻你
    2021-01-22 14:39

    They are loaded when needed. But what "when needed" means, might depend on the classloader. Typically, when a class is loaded it also checks the existence of all classes it references - and it might also load them.

    You can check it by adding the option -verbose to your Java JVM, it outputs then all the classes it loads, and from where.

提交回复
热议问题