What is a Java ClassLoader?

前端 未结 7 2001
眼角桃花
眼角桃花 2020-11-29 14:24

In a few simple sentences, what is a Java ClassLoader, when is it used and why?

OK, I read a wiki article. ClassLoader loads classes. OK. So if I include jar files a

7条回答
  •  迷失自我
    2020-11-29 14:59

    Most Java developers will never need to explicitly use class loaders (except to load resources so that it still works when they're bundled in JARs), let alone write their own.

    ClassLoaders are used in large systems and server applications to do things like:

    • Modularize a system and load, unload and update modules at runtime
    • Use different versions of an API library (e.g. an XML parser) in parallel
    • Isolate different applications running within the same JVM (ensuring they don't interfere with each other, e.g. through static variables)

提交回复
热议问题