Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6931579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:35:46+00:00 2026-05-27T11:35:46+00:00

Can a java classloader load a class more than once, ie load new versions

  • 0

Can a java classloader load a class more than once, ie load new versions of a class, without throwing a LinkageError of “duplicate class definition”?

In other words, if we need to dynamically reload a class, can this be done with the same classloader, or does the classloader have to be destroyed first and a new one be created that will load the new version of the class?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:35:46+00:00Added an answer on May 27, 2026 at 11:35 am

    A classloader can only actually load a class once! That means that it can only define it once. It can load it many times, but only the first time it will define it. The rest of the times it will load the existing instance it has already defined from the first time.

    Trying to define a class twice causes a LinkageError of “duplicate class definition”. If there is a need for classes to be loaded and reloaded many times then this must be done by different classloaders like this:

    Create a classloader of your own that will load your classes. When you want to reload any class you must destroy your classloader and then create a new instance of it that will load the new versions of your classes.

    Of course, this causes an extra load, but if you need it that is OK.

    Also, be careful to not leave any references of your classes lying around when destroying the old instance of your classloader, as this will cause a memory leak!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I make a new ClassLoader and make it define a new Class , which
The RFC for a Java class is set of all methods that can be
I am using the following code to dynamically load a class in java: URL
Can a Java Applet able to print out text/html easily to standard printer driver(s)
In Java can I create a URI for a file located locally in the
With iText I can use Java to open a pdf and write it. If
(Yes I know I can call Java code from Scala; but that is pointless;
Is there anything simple Java can't do that can be done in a similar
With the regular statement (just statement) I can put java enums into the queries
What is the maximum file size 32 bit java can access? Is this architecture

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.