Does jvm load all the classes mentioned by the classpath?

后端 未结 5 885
北恋
北恋 2020-12-15 10:12

When we invoke java command with -cp command then we provide some directories and jar files. Does jvm load all the classes mentioned by the classpath Or it is just a super s

5条回答
  •  轮回少年
    2020-12-15 10:53

    Does jvm load all the classes mentioned by the classpath Or it is just a super set of all classes which jvm will look up to load when required?

    JVM loads classes form the classpath on the need basis i.e. when a reference is found for the class, it is loaded. Also there is a hierarchy of class loaders in JVM, a class loaded by the parent class loader is used by the lower class loaders.

提交回复
热议问题