Java class loading mechanism-how to implement different modules in a project load different versions of the jar package with the same name.

Source: Internet
Author: User

How do I implement a project in which different modules load different versions of the jar package with the same name?

It was Ali's interview when he met a face test. At that time a bit dizzy, if it is usually encountered such a problem must be unified load the same version of the good.

It is really necessary to address such problems if the system is particularly large and relies heavily on conflict and involves multi-sectoral coordination.

The problem has plagued me for a long time and there has been no good solution. Recently studied Java virtual machines. Finally found the answer.

In the JVM, different Java types are distinguished by class name and ClassLoader. As a result, the JVM allows us to load Java classes of the same namespace with different loaders, while in fact these same namespace Java classes can be completely different classes.

Usually we use the default class loader, so a class with the same name or a jar package with the same name is unique and cannot load different versions of the jar package with the same name. The different loaders in the JVM are Java classes that can load the same namespace.


Java class loading mechanism-how to implement different modules in a project load different versions of the jar package with the same name.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.