Is it possible to unload a class?

Suppose I take a classloader and load a class. Then I set my classloader to null and get rid of any objects of it that I've instantiated. Can that class be garbage collected?
I'm thinking that it probably isn't possible. Even if you can get rid of all references to the class, what if a thread is running a static method of that class? But then again I suppose the stack trace would then have a reference so it can't be garbage collected. Was also thinking about what if a thread is just about to call it, but I guess you could just pop a classNotFoundException. So maybe it is possible... Can anyone comment?

Well... I'm pretty sure it's possible to unload a class since it's possible to replace them. My IDE (IntelliJ) is capable of recognizing a change in your class file (as a result of compilation while the program is running, for example) and inserting the new class into the application if you want. This is very handy for working on web applications wherein the server takes a while to reload the application.
So if you can reload the class, you can probably unload it, yes?

Similar Messages

  • Is it possible to unload a class thru the standard Classloader

    is it possible to unload a class thru the standard Classloader,
    I mean during runtime..

    If you want do unload any class then create separate custom class loader and load it with it.
    When you don't need anymore that package you can simply set your custom class loader to null and the next time GC is invoked it may free the memory.
    If you want to free it right after you don't need that package anymore you should call System.gc() twice -
    this usually works.

  • Loading and Unloading of Classes

    Hi All,
    I m trying to use the Digester APIs for XML parsing. Iam using the version 1.6. However, on the server where the application will be deployed, the Digester JARs already exist but an older version.
    due to some reason these old JARs cannot be unloaded or replaced with the latest JARs.
    My question is it possible to force load my new JAR and use it?
    Is it possible to unload the old JAR and reload the new one using a customised Class Loader?
    I am using IBM Websphere 5.1
    any inputs wud be highly appreciated!
    Thanksm
    gunjan sahay

    You cant unload the existing classes. Depending on how the server uses its classes you can get it to use some from your preferred library though.
    You can use a URL classloader to load your classes and use only those classes returned from that classloader. A lot of people on the Eclipse forums had to conquer the same issue.
    But i cant say if it will work. Depends on how the server finds the classes. if it asks you for the classloader, you are set, if not you are hosed.

  • Is it possible to call a class method using pattern in ABAP editor.

    Hi,
         Is it possible to call a class method using pattern in ABAP editor.
    Thank U for Ur time.
    Cheers,
    Sam

    Yes,
    Click patterns.
    Then choose Abap objects patterns.
    Click on the Tick
    It will give a new screen
    Here Give the name of the class first.
    Then the object (instance of the calss)
    And finally the method ..
    it will give you the pattern
    Hope this helps.

  • Is it possible to call a class in a jar file from JNI environment?

    Hi
    Is it possible to call a class in a jar file from JNI environment?
    Thanks in advance.

    Could you explain a bit more what you are trying to do? (In other words, your question is vague.)
    o If your main program is written in C, you can use JNI to start a JVM, load classes from the jar of your choice, and call constructors and methods of the objects defined in the jar.
    o If your main program is java, and has been laoded from a jar, a JNI routine can call back into java to use the constructors and methods of classes defined in the jar(s).

  • Is it possible to override super class constructor?

    Is it possible to override super class constructor form subclass?

    However, you can achieve do something that looks similar to overriding.
    class Parent {
      Parent(int i, String s) {
        // do stuff
    class Child extends Parent {
      Child(int i, String s) {
        super(i, s);
        // do Child stuff here
    new Parent(1, "abc");
    new Child(2, "xyz");Although that's not overriding, it sort of looks similar. Is this what you were talking about?

  • Back posting only possible with same valuation class

    Hii, I made changes in valuation class before that i closed all the open po and maintained stock zero using 201 mvt type on 31st March. Now the system is throwing error when Im doing the reversal using MB1A 202 mvt type like "Back posting only possible with same valuation class". But its taking if I take the Posting date to 1st April, and we want to post on the 31st MArch. Please provide the suggestion.
    Thanks,
    Manoj

    System is behaving correctly..
    Suppose you have changed the valuation class from X to Y as on 31.03.2014.
    So your valuation class was X as on 31.03.2014.
    But now your valuation class is changed as Y. and system will always try to post the valuation class Y for material.
    So when you are trying to reverse the entry on 31.03.2014, system shows the error..
    In that case, you should change the valuation class as on 30.03.2014 and you should do 201 movement type as on 30.03.2014, and then as on 31.03.2014, you can reverse the entry..
    Now you have to reverse the 201 movement type after date 31.03.2014.
    Regards
    Dev

  • How to unload a class or a dll from jvm?

    We can load a class or a dll into jvm,but how can we unload a class or a dll from jvm?
    I'm look forward to your reply.
    Regard!
    Sun.Huang

    i don't believe you can unload a class.A class can only be unloaded if its classloader
    becomes unreachable, so classes loaded by the
    bootstrap loader will never be unloaded.Are they definately unloaded in that case? as soonas
    the classloader that loaded them is unreachable?or
    is it still an optional decision for the jvm?A class may be unloaded if and only if its defining
    classloader may be reclaimed by the garbage
    collector. There are no guarantees that a class will
    be unloaded.Okay, that's what I thought. Thanks for confirming.

  • Is it Possible to assign Valuation class without accounting view in MM

    Hi all,
    I have check my client system for materials having without accounting view while checking in table mbew for this material having valuation class.can anyelse say is it possible to assign valuation class without having  accounting view.
    Advance thanks,
    raraja

    Hello ,
    It is not possible to have a valuation class without accounting view.
    There is some mistake that you are possibly making . pls check the same .Pls check if u r viewing the material master at the correct plant level .Also if you say that in MBEW valuation class exists , find out l the corresponding valuation level, the see the material master at the same level . You will definitely find the accounting view.
    Regards
    Anis

  • Is it possible to compile/convert class/jars to DLL?

    Hi all,
    Is it possible to compile/convert class/jars to DLL so that my VB program can use it? If yes, how do i do it?
    thanks for your time.

    No it is not (afaik). But as far as the VB stuff goes, somebody who posted here earlier mentioned passing data to VB functions. Can't remember which post it was.
    One thing you can do is use sockets to send data between your Java code and VB application using sockets. Sockets are easy to use in Java, and in VB you just need to use the stuff in ws2_32.dll. You can find VB modules for sockets all over the place.
    Jason

  • Re: Possible to unload classes?

    You make a classloader that is loading classes from somewhere other than the classpath.

    ArkAvon wrote:
    Alright, what I am trying to do is to allow the user to input a java class file into a text editor within the program.You mean a java source file.
    Then the program will take the code, compile it into a classfile, and then load it via a classloader and start it executing. Now, if the user alters the code in his box and saves it again as the same filename, the same classname is used in compilation and then the classloader tries to load the new class, but it has the same name as the old one, so it just uses the old one. I need to get rid of the old one.
    So as noted you are not loading it via the custom class loader. That is a matter of the output dir being in the VM class path. It should be.
    Is the classpath just the path of the classes of the program being run? The class path is the class path. In the Sun VM it consists of a user configurable path along with the VM paths.
    Even with this set up, it still bucks it back up to bootstrap loader.Because you have it in the VM class path.

  • Is it possible to maintain two class type for a material

    Dear All,
    Is it possible to maintain two different class type for a material.
    If a material assigned with the batch and the material is a part of variant configuration, then how to handle this scenario.
    For Batch Management, class type will be 023, for Variant Configuration class type will be 200.
    How to handle this scenario.
    Please explain.
    Regards,
    Mullairaja
    Edited by: MullaiRaja on Jan 5, 2011 5:19 AM

    Mr.Raja
    As far as my knowledge, it does NOT make sense to assign a material to more than one class type.
    We can assign many classes to  a single class type of  a material.
    For configurable material, create the material using material type : KMAT.
    & then, activate the 'batch management" control in the material master, for that material.
    Pls revert with feedback.
    Hope, that helps you.
    Rgds
    Sumanth.Gururaj
    Consultant/Systems Analyst - SAP SD/MM

  • Is it possible to Remote Enable Classes in ABAP

    Hi,
    I am exploring options on the possibility of remote calls for Classes, like we have RFC for FM's.
    I found a category value - 30 Proxy class for remote interface in the class properties in se24, however i was not able to select this option while creating new class.
    Any pointers on this would be of great help.
    Regards,
    Uday

    No, afaik it is not possible to directly expose the methods of a class for remote calling.
    Of course you can create an rfc FM and call methods from within the FM.
    Regards,
    Thomas

  • Is it possible to instantiate arbitrary classes at runtime??

    Hi,
    I was wondering if it is possible to instantiate an arbitrary class at runtime using its class name.
    My plan is to have a collection of java classes in a folder, which could be instantiated and have their member methods called. This collection of classes however, could change at any time. I'd like to be able to specify which class to work with at runtime, using a string containing the class name to identify it.
    Is this possible using java?? If so, how?
    Thanks in advance.

    It's called reflection.
    Class someClass = Class.forName("some.package.SomeClass");
    ...

  • Is it possible to execute simple class

    Sir,
    Is it possible to execute a simple program written in java in
    jdeveloper. If yes please let me know how to that.
    I creted a class using class wizard and added the following
    statement;
    System.out.println("testing");
    I able to compile the program without error, but how to execute
    it.
    raghu
    null

    Hi Jun Wu,
    Because without deploying, it doesn't allow me check how my java webdynpro application works!!
    I  need to execute my java web dynpro application and I dont have any access to SDM pins/passwords.
    Please share your valuable thoughts on the same.
    regards,
    Ajeeth Kumar S

Maybe you are looking for

  • Download movies from home sharing?

    I ripped most of my DVDs so I can play them through Apple TV, etc. I share them via iTunes using home sharing. However, I want to be able to download movies from that shared library directly to my iPad and/or iPhone so I have them when I travel. I re

  • Is there a way to restore the earlier color-coding format?

    If there is a workaround to restore the earlier color-tag format, I would love to know it. In the alternative, I've submitted the following to Apple and wanted to share it with the community also, in case there is no workaround and others would like

  • How do I only show typed URLs in the Top Sites screen?

    It's really obnoxious to see hundreds of ephemeral URLs that you'll never visit again on the Top Sites screen. Is there a way to make this user friendly so I can only see the URLs I typed. I am happy to set something in about:config.

  • What is a sparse bundle?

    I purchased the AirPort Time Capsule and a new iMac.  I also have 2 old MacBooks (the white ones) that are about 8 years old with old operating systems.  I created a network using the Airport Time Capsule, and now I am trying to access the content fr

  • HT204053 how do i update my ios on my iPhone ?

    how do i update my ios on my iPhone ?