Get all th loaded classes

Dear ppl,
I have been trying so hard to get a solution to the following problem:
I needed to know the name of the classes currently loaded in the jvm in a dynamic fashion ie any time I should be able to query jvm and get the list of currently loaded classes (which should not show the unloaded classes). I wanted to keep it simple so I avoided using jpda api. I found an article in java world which says:
If you really insist on monitoring classes loaded by absolutely every possible classloader in the JVM, it is hard to do so in pure Java.
You might try forcing every classloader instance to register itself in some global data structure. For example, if you modify both java.lang.ClassLoader constructors:
    protected ClassLoader() {
    SecurityManager security = System.getSecurityManager();
        if (security != null) {
            security.checkCreateClassLoader();
    this.parent = getSystemClassLoader();
    initialized = true;
    ClassLoaderRegistry.register (this);
    protected ClassLoader(ClassLoader parent) {
    ClassLoaderRegistry.register (this);
to call into the following class:
public abstract class ClassLoaderRegistry
    public static void register (final ClassLoader loader)
        if (loader != null)
            synchronized (CLASSLOADER_SET)
                CLASSLOADER_SET.put (loader, null);
    public static ClassLoader [] getClassLoaders ()
        final List /* ClassLoader */ resultList = new LinkedList ();
        synchronized (CLASSLOADER_SET)
            // We are using a weak map: be careful when traversing the key set
            // [it's unsafe to use resultList.addAll(CLASSLOADER_SET.keySet())]
            for (Iterator keys = CLASSLOADER_SET.keySet ().iterator (); keys.hasNext (); )
                // Note that WeakHashMap guarantees that the weak key will not be
                // cleared between hasNext() and next():
                resultList.add (keys.next ());
        final ClassLoader [] result = new ClassLoader [resultList.size ()];
        resultList.toArray (result);
        return result;
    // This field is used as a 'weak set' to avoid interfering with class
    // and classloader unloading and garbage collection:
    private static final WeakHashMap /* ClassLoader->null */ CLASSLOADER_SET
        = new WeakHashMap ();
} // End of class
you will in fact track every classloader instance created in the JVM. This happens because every classloader constructor eventually chains all the way down to one of the above two constructors. Then you can use ClassLoaderRegistry.getClassLoaders() followed by the usual ClassScope.getLoadedClasses() to get a full class listing snapshot.
Of course, you need to deploy both the modified java.lang.ClassLoader and ClassLoaderRegistry in the JVM's bootstrap classpath (using the -Xbootclasspath/p: JVM option) to make this work. This approach is probably only for dedicated Java hackers.
Now I did exactly what they said. But I get compile time error with the modified ClassLoader.
So now is there any other workaround? Can you please help me out?

hi,
Let me explain u in detail.
I have a JTextPane through which i load an image.Here is a code snippet
HTMLEditorKit kit = new HTMLEditorKit();
JTextPane jtp1=new JTextPane();
jtp1.setEditorKit(kit);
jtp1.setEditable(false);
jtp1.setSize(100,100);
jtp1.setText("<img src="top1.gif">");
I add this JTextPane jtp1 to a panel.There are two JTextPane holding different images which are added to apanel in turn.
When i add these(jtp1,jtp2) to a panel ,then i sometimes see the blank panel.jtp1 and jtp2 does not appear on that.
So what should i do so that only when all the components are loaded (here jtp1 and jtp2) then only my panel holding jtp1 and jtp2 is displayed.
Thank you
vineet

Similar Messages

  • Overriding eventdistributionpattern-pof throwing unable to load class error

    Hi,
    We were trying to override the "coherence-eventdistributionpattern-pof-config.xml" with our own event distribution pof due to conflicintg type-id's. We changed type-id's for few of the classes. We changed the type-id for the following classes and left others as such.
    com.oracle.coherence.patterns.eventdistribution.EventDistributor$Identifier
    com.oracle.coherence.patterns.eventdistribution.events.DistributableEntry
    com.oracle.coherence.patterns.eventdistribution.events.DistributableEntryInsertedEvent
    com.oracle.coherence.patterns.eventdistribution.events.DistributableEntryUpdatedEvent
    com.oracle.coherence.patterns.eventdistribution.events.DistributableEntryRemovedEvent
    When i start the coherence server, i get error in loading class "com.oracle.coherence.patterns.eventdistribution.channels.cache.ParallelLocalCacheEventChannelBuilder" for which we did not change the typ-id at all.
    Coherence version 3.7.10
    Error Trace:
    (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=2): PartitionedCache caught an unhandled exception (com.tangosol.util.WrapperException: (Wrapped: error creating class "com.tangosol.io.pof.ConfigurablePofContext") (Wrapped: Unable to load class for user type (Config=test/coherence/grid/obj-pof-config.xml, Type-Id=13402, Class-Name=com.oracle.coherence.patterns.eventdistribution.channels.cache.ParallelLocalCacheEventChannelBuilder)) (Wrapped) com.oracle.coherence.patterns.eventdistribution.channels.cache.ParallelLocalCacheEventChannelBuilder) while exiting.
    <Error> (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=2): ClusterService.doServiceLeft: Unknown Service PartitionedCache{Name=DistributedCacheForSequenceGenerators, State=(SERVICE_STOPPED), Not initialized}
    (thread=DistributedCache:DistributedCacheForSequenceGenerators, member=2): Service DistributedCacheForSequenceGenerators left the cluster
    <Error> (thread=main, member=2): Error while starting service "DistributedCacheForSequenceGenerators": (Wrapped) (Wrapped: error creating class "com.tangosol.io.pof.ConfigurablePofContext") (Wrapped: Unable to load class for user type (Config=test/coherence/grid/obj-pof-config.xml, Type-Id=13402, Class-Name=com.oracle.coherence.patterns.eventdistribution.channels.cache.ParallelLocalCacheEventChannelBuilder)) (Wrapped) java.lang.ClassNotFoundException: com.oracle.coherence.patterns.eventdistribution.channels.cache.ParallelLocalCacheEventChannelBuilder
            at com.tangosol.coherence.component.util.Daemon.start(Daemon.CDB:52)
    Thanks,

    File's permissions?

  • Load:Class * not found - in portal

    In the webgui /portal a link is provided.
    when you click the link , which is mapped with the transaction
    code of the ABAP program. gets displayed.
    THis program is used to download PO into the File
    server.
    so File output path is given.
    The user uses F4 help to select the directory / filename as well
    In the bottom we are getting a messge
    load: class FileName not found
    and load: class Directory Select not found
    I use cl_gui_frontend_services=> directory_browse
    and kd_get_filename_on_f4.
    wat might be the problem for this?
    Give me your valuable suggestions
    This is urgent.

    Hi,
    the abap code you use, uses java for getting a filename and for directory browsing. So first of all you have to check,
    if java is activated in your browser. Second, you have to test the frontend services in webgui with transaction se37, ws_query, enter "cd" into field query and executer this. Then you will get a security popup, which you have to accept. If all runs ok,
    you will get the current home directory as result. If you get a java exception again, you have to check the network configuration
    in the java control. It should be the same, as in the browser. If this does not help, try to request the applet ws.jar from the mimerepository .../sap/its/mimes/webgui/2002/applets/ws.jar
    directly. Do you get the security dialog? The error you wrote above means, that the java applet ws.jar could not be loaded.
    Is this an inhouse problem? external or integrated IITS. Which browser, which java version?
    Regards,
    Ralf

  • Problem with loading classes!!!

    I am loading classes using
    // Open File
    InputStream jarFile = new BufferedInputStream(new FileInputStream(
    pluginPath));
    // Get Manifest and properties
    Attributes attrs = new JarInputStream(jarFile).getManifest().
    getMainAttributes();
    jarFile.close();
    // Read Main Class
    String mainClass = attrs.getValue("Protocol-Class");
    // Load all classes from jar file without giving classpath
    URL url = new URL("jar:file:" + pluginPath + "!/");
    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
    URL[] urls = new URL[] {
    url};
    ClassLoader classLoader = new URLClassLoader(urls);
    // Create new instance of protocol
    Protocol protocol = (Protocol) classLoader.loadClass(mainClass).
    newInstance();
    I am loading classes one by one say a order A, B, C. In my case class c extends class A. So I am loading class A first and later B and finally C. But I am getting exceptions when loading class C that Class A is unknown.The following exception is thrown
    java.lang.NoClassDefFoundError: com/a/A at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    Please give me a solution to make it run.

    You create a new class loader for each class. The class loaders are independent, and so the class hierarchies they load are independent. Class A loader by classLoaderOne doesn't see class B loader by classLoaderTwo - they are loaded into their own sandboxes.
    Either load everything with one class loader or create the class loaders in a hierarchy. To create a hierarchy use the class loader constructor that takes a parent class loader as a parameter. One class loader may be easier because then you don't need to worry about loading order.

  • Loading .class files for reflection

    I'm trying to write a program that lets the user select thier .class files to gather
    information about those classes with reflection.
    I can't figure out how to get ClassLoader to load .class files outside the program
    directory.

    I've tried both these options, and spent some time on it too,
    but failed. If can't find a class that can load clases form a URL
    how can I write my own ClassLoader that does it.
    The ClassLoaders all seem to assume that they already know where
    to look for the class files. Perhaps if I could tell them where to look,
    but I don't see how.

  • Load:Class filename not found portal

    In the webgui /portal a link is provided.
    when you click the link , which is mapped with the transaction
    code of the ABAP program. gets displayed.
    THis program is used to download PO into the File
    server.
    so File output path is given.
    The user uses F4 help to select the directory / filename as well
    In the bottom we are getting a messge
    load: class FileName not found
    and load: class Directory Select not found
    I use cl_gui_frontend_services=> directory_browse
    and kd_get_filename_on_f4.
    wat might be the problem for this?
    Give me your valuable suggestions
    This is urgent.

    Hello,
    Can you tell us if you resolve your issue and how?
    Thanks

  • "load: class */*.class not found." error

    Hi...I'm making an applet in SUN ONE, and when I try to run the program, the applet doesn't initialize, and I get this error:
    load: class LSLENDB/LSLENDB.class not found.
    It doesn't tell me anywhere in my file where the error comes from. Note that the file is LSLENDB.java, and the class is named the same (LSLENDB). Any suggestions?

    but i don't agree with your suggestion,
    because he put his files in package, he must use:
    <applet codebase=".." code="LSLENDB" .......></applet>
    if he would like to have applet tag like:
    <applet code="LSLENDB"></applet>
    he should remove "package LSLENDB;" line from head of his applet source code.

  • Getting all classes loaded by ClassLoader?

    How do you get an array of type (Class []) that represents all the classes loaded by a ClassLoader?
    Thanks
    neofreezer

    but if you do, that means that u can't load classes whose packages start with 'java.'!

  • How can i get all java class names from a package using reflection?

    hi,
    can i get all classes name from a package using reflection or any other way?
    If possible plz give the code with example.

    You can't, because the package doesn't have to be on the local machine. It could be ANYWHERE.
    For example, via a URLClassLoader (ie from the internet) I could load a class called:
    com.paperstack.NobodyExpectsTheSpanishInquisitionI haven't written it yet. But I might tomorrow. How are you going to determine if that class is in the package?
    This subject comes up a lot. If you want to do something a bit like what you're asking for (but not quite) there are plenty of threads on the subject. Use google and/or the forum search facility to find them.
    But the answer to your question, as you asked it, is "you can't do that".

  • To get all the objects that are used inside the class

    Hi All,
    All i wanna know is to get all the objects that are used inside the class.
    Ex :
    Class A{
    Emp e;
    public add(Dept d){
    e.deptid = d.deptId;
    in this class i have two objects, one Emp obj and another Dept object.
    I wanna get the details abt this class Emp and Dept by simply parsing the file and by not loading this class in JVM.
    Could any pls hel me out.??
    thx.

    I wanna get the details abt this class Emp and Dept
    by simply parsing the file and by not loading this
    class in JVM.Your problem statement is vague and the constraint is IMO hypothetical.

  • Do not seem to be able to backup iPad via iTunes on to my PC. Message after connecting is "iTunes was unable to load class information from Sync Services, Reconnect or try later"  Have tried that but get the same result. Can anyone assist?

    Do not seem to be able to backup iPad via iTunes on to my PC.
    Message after connecting is "iTunes was unable to load class information from Sync Services, Reconnect or try later" 
    Have tried that but get the same result.
    Remedies I've tried are:
    wait and try again
    reboot
    reload iTunes
    NB hp is a relatively new machine and has previously backed up quite happily.
    Can anyone assist?

    RHoodnkt-
    Try rebooting the iPad.  Hold down both the Home and Sleep buttons for several seconds until the Apple logo appears.  Ignore the "Slide to power off" arrow.  It takes a minute or two to restart.
    Also be sure your iPad battery is not completely discharged.
    Fred

  • Since upgrading to Aperture 3.3, when I try to sync photos to my iPhone, I'm getting all versions in a stack loading onto my phone, which makes for some ugly pics, as well as taking up nearly double the space.

    Since upgrading to Aperture 3.3, when I try to sync photos to my iPhone, I'm getting all versions in a stack loading onto my phone, which makes for some ugly pics, as well as taking up nearly double the space.

    Could it be the problem lies with iTunes and not Aperture?  iTunes 10.6.3 was released on the same day as Aperture 3.3 --  June 11.
    If someone has a configuration to test an older version of Aperture with iTunes 10.6.3 to see if the problem exists, that could be helpful.

  • I have completely downloaded all parts of master suite (I attend AAU so it's provided by school) however, I can get nothing to load and operate. I am still running XP but my understanding is that it should still work for most apps

    I have completely downloaded all parts of master suite (I attend AAU so it's provided by school) however, I can get nothing to load and operate. I am still running XP but my understanding is that it should still work for most apps

    I believe you need to have XP with Service Pak 3 as a minimum for most CS6 applications.  You should check all of the system requirements because I think you also need to have a 64-bit machine as well.   Here is a link...
    System requirements | Adobe Creative Suite 6

  • On the zynga game, mafia wars, every time i click on something within the game a get a popup that says "Requested URL not found: 400" all pages load fine it just gives the message every time i click something, how can i stop this?

    on the zynga game, mafia wars, every time i click on something within the game a get a popup that says "Requested URL not found: 400" all pages load fine it just gives the message every time i click something, how can i stop this?

    Sorry, the above thread should have been a "new" post, not a reply post.

  • When i start ifind i get message about load error. i click reload option and icloud main screen opens ifind shows a map that is misaligned. phone shows several blocks away. can play sound thru ifind and acess info on phone. all os upto date. any idea

    start ifind from web on my dell pc with win 7. get error on load to retry later or reload. click reload and icloud main screen comes up. I hit ifind and phone shows up on a misaligned map and is shown several blocks from actual location. tried daughters phone and map shows up inaccurate for hers also. I have 4s she has 5c all ios on phones are updated . I can get phone to sound and access data such as contacts, calendars.  the problem with bad map and message that there is a problem on starting. previously the map had no problems and location was accurate to within a short distance.

    Thank you for the sympathy and the information about the Adobe.com forum Michael.
    I posted here because, to be honest, for a company that's acknowledged their installers and updaters and support needs some work, they seem very determined to obfuscate the means by which users can provide direct feedback to the company. Much like you, I've also noticed a trend in CS5 installations that mirrors the issues that were present in CS4. it's a sad state of affairs.
    As for my installation, you are also quite right to say that a clean install would have been a lot faster than what I went through with TS and it was actually my first idea. Before calling TS I'd actually read through the forums and noticed that a large number of users who were faced with my situation had no other choice but to reformat. I was just giving Adobe the benefit of the doubt and wasted 2 and a half weeks through that course of action...
    What makes this situation even more frustrating is that the installer failed on a fresh system. It was a custom-built design machine, assembled and configured by myself. The only software that had been installed on it prior to Design Premium was Firefox, an FTP client and the start of my problems, trial versions of various CS4 programs. I used trials just long enough to retire the previous design computer so that I wouldn't contravene the EULA's stipulation of not running more than one instance of software at the same time on different machines.  Turns out being honest once again penalised a legal customer.
    If there is just thing users should learn from my far from unique tale of failed tech support it's that if you ever run into a problem with the installation, don't bother calling TS, just reformat and start from scratch.  It might seem like it'll take longer to get going again, but in actuality, it's the opposite. Reformatting means you'll be up and running in about 1 or 2 days rather than 2 weeks.
    Marc

Maybe you are looking for