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 8769699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:24:22+00:00 2026-06-13T17:24:22+00:00

public class ClassScanner { // scan extraClasspath for specific classes public List<Class<?>> scanClasspathForClass(String scanCriteria)

  • 0
public class ClassScanner
{
  // scan extraClasspath for specific classes
  public List<Class<?>> scanClasspathForClass(String scanCriteria)
  {
    ...
  }

  public static Class<?> reloadClass(Class<?> clazz, ClassLoader clazzLoader)
  {
    // Question: how to reload a loaded class (ClassScanner in this example) with a different arbitrary ClassLoader?
  }

  // an example of how reloadClass() would be used
  // in real case, this function would be in different class
  public List<Class<?>> scan(URL[] extraClasspath)
  {
    URLClassLoader urlClazzLoader = new URLClassLoader(extraClasspath, null);
    Class<?> newClass = reloadClass(ClassScanner.class, urlClazzLoader);
    return ((ClassScanner) newClass.newInstance()).scanClasspathForClass();
  }
}

Above code demonstrates the question and why it is a question. I need to implement reloadClass(). I wonder if there is a reliable solution in Java 1.6. One useful reference would be Find where java class is loaded from.

Thanks for help!

  • 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-06-13T17:24:23+00:00Added an answer on June 13, 2026 at 5:24 pm

    Found myself the answer from http://www2.sys-con.com/itsg/virtualcd/java/archives/0808/chaudhri/index.html.

    Basically what I need is to make one ClassLoader A to share its namespace with another ClassLoader B. The way I found to achieve this is to use the ClassLoader parent-delegation model. Here, ClassLoader A is the parent ClassLoader.

    public List<Class<?>> scan(URL[] extraClasspath) throws Exception
    {
      URLClassLoader urlClazzLoader = new URLClassLoader(extraClasspath, ClassScanner.class.getClassLoader());
      return urlClazzLoader.loadClass(ClassScanner.getName()).newInstance();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class A { private A(int param1, String param2) {} public static A createFromCursor(Cursor
public class RefMix { public static void main(String[] args) { Object[] a = {null,
public class Father { // static string TYPE = FATHER; public Father() { //Console.WriteLine(ctor);
public class demo { public static void main(String[] args) { for(int k = 2029;
import java.util.scanner; import javax.swing.JOptionPane; public class FirstHomeJavaApplet{ public static void main(String[] args){ int num1=2;
public class Base{ protected String str; public static final Base ERROR = new Base(error);
public class Demo { public static void main(String args[]) { double d = 12.345;
public class DBAdapter { public static final String COLUMN_ID = ID; public static final
public class Test{ public void Test(String name){}; public static void main() { Test t=new

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.