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.

Similar Messages

  • How to convert java .class file to .dll file

    hi,
    I got a problem, I have to convert my java .class file to .dll file. Microsoft VC++ program will invoke the converted .dll file.
    Is there any other possibility.
    I was confused.
    Cam any body help me. If you are having solution for the can you send to my [email protected] account.
    thanks,

    No, it is not possible to do what you are suggesting. Yes, you could produce a DLL that wraps the JVM and loads your java class exposing a C and/or C++ callable interface, but that is a lot to go through unless your class is VERY complex. Otherwise, you might want to just create and maintain two implementations.

  • How to find the class name, the location from where it invoked a method

    Hi,
    I have a class A. The caller calls A.someMethod(), whenever this method is invoked, I want to find out the caller info, which class invoked this method, from where this class was loaded (may be the jar file name). Any help will be appreciated.
    Thanks.

    However since version 1.4 there is an easier way to extract that information from the Throwable:
    java.lang.Throwable
    public StackTraceElement[] getStackTrace()
    Provides programmatic access to the stack trace information printed by printStackTrace(). Returns an array of stack trace elements, each representing one stack frame.

  • How to know which class is being loaded from which jar file & path location

    Hi,
    I have some Java code using several jar files.
    I want to remove those jar files which are not being used by the code.
    So , I want the JVM to output which class is being loaded from which jar .
    Using "java -verbose" option doesnt solve the problem because the required info is printed only for the classes/jars native to the J2SE package .
    Can anyone provide a solution which does not require me to modify the code?
    Thanks,
    Danish

    Classpath Helper

  • How do I call a LabVIEW created DLL from within Microsoft Excel (VBA)?

    Hi,
    I'm trying to get Microsoft Excel 2003 to call a function stored in a dll that I created using LabVIEW 7.1.  The function is very simple and is called "binary_file_to_ascii".  Basically it just reads a LabVIEW created binary spreadsheet file and outputs the columns as float arrays.
    The function arguments are as follows:
    INPUT : String that contains the path to the binary spreadsheet file
    OUTPUT : Number of rows in the spreadsheet
    OUTPUT : Number of columns in the spreadsheet
    OUTPUT : Float array containing the elements in column 1
    OUTPUT : Float array containing the elements in column 2..
    OUTPUT : Float array containing the elements in column 11
    However, for some reason there is something wrong with my VBA code and/or the way I created the DLL in LabVIEW because Excel crashes when it loads my DLL.
    What do I need to change in my VBA code or my LabVIEW DLL build settings to fix this?
    I've attached to this post a ZIP file that contains all my code and a sample binary file.
    Your help with this will be much appreciated.  Thanks!
    Richard
    P.S.  Here is the VBA code I'm using:
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    ByVal column2 As Variant, ByVal column3 As Variant, _
    ByVal column4 As Variant, ByVal column5 As Variant, _
    ByVal column6 As Variant, ByVal column7 As Variant, _
    ByVal column8 As Variant, ByVal column9 As Variant, _
    ByVal column10 As Variant, ByVal column11 As Variant)
    Private Sub load_binary_spectra()
      Dim nrows, ncols As Long
      Dim col1(), col2(), col3(), col4(), col5(), col6(), _
          col7(), col8(), col9(), col10(), col11() As Variant
      Dim lRetVal As Long
      Dim spectra_path As String
        spectra_path = "C:\temp\binary_file_to_ascii\sample_binary_file\sample_binary_file.dat"
        lRetVal = binary_file_to_ascii(spectra_path, nrows, ncols, _
                  col1(), col2(), col3(), col4(), col5(), col6(), _
                  col7(), col8(), col9(), col10(), col11())
        MsgBox (spectra_path)
    End Sub
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Message Edited by Richard Ballantyne on 07-25-2007 02:39 PM
    Attachments:
    binary_file_to_ascii.zip ‏192 KB

    Hi,
    I don't know anything about Visual Basic, but here's my guess.
    When you load the DLL with this line of code
    Private Declare Function binary_file_to_ascii Lib "C:\temp\binary_file_to_ascii\binary_to_ascii.dll" _
    (ByVal binaryFile As String, ByVal nrows As Long, ByVal ncols As Long, ByVal column1 As Variant, _
    You are defining how the parameters are sent. It seems that all are sent by value (ByVal), but in the DLL header, some of the function's
    parameters are defined as pointers(see the function prototype below, look for asterisk(*))
    void __stdcall binary_file_to_ascii(PStr binaryFile,
                                                    long *numberOfRows,
                                                    long *numberOfColumns,
                                                    float column1[],
                                                    float column2[],
                                                    float column3[],
                                                    float column4[],
                                                    float column5[],
                                                    float column6[],
                                                    float column7[],
                                                    float column8[],
                                                    float column9[],
                                                    float column10[],
                                                    float column11[]);
    Can you define in VBA that you want to use pointer instead? Maybe by using ByRef (as by reference).
    Hope this helps.

  • How to Refer a class of Model Layer From a Class of View Layer IN Struts?

    HI There !
    I am building an application on struts using JDeveloper 10.1.3.1. On Selecting New application and writing few classes this is my Application Hierarchy is like folowing:
    Application Name
    |___ Model (Project given by Jdeveloper)
    | |_____ Application Resources
    | |________ model (Package)
    | |__________ CheckUser.java
    | |__________ DataAccess.java
    |
    |___ ViewController(Project given by Jdeveloper)
    |________ Application Resources
    |__________ View (Package)
    |__________ logon.java
    I tried to use CkeckUser.java in logon.java by importing the package model.
    But Jdeveloper is showing an error which means that this Package is not available here.
    So then how I can refer this class at View layer classes.

    Hi Ankur,
    I'm facing the same problem, i need to access a method in the AppModuleImpl but when i try to call it from an action in my viewController this error pops out:
    Error: cannot access class oracle.jbo.server.ApplicationModuleImpl; file oracle\jbo\server\ApplicationModuleImpl.class not found
    Did you have some advances with this?
    Please let me know
    Thanks

  • How to access data structures in C dll from java thru JNI?

    We have been given API's( collection of C Functions) from some vendor.
    SDK from vendor consist of:
    Libpga.DLL, Libpga.h,Libpga.lib, Along with that sample program Receiver.h (i don't know its written in C or C++), I guess .C stnads for C files?
    Considering that I don't know C or C++ (Except that I can understand what that program is doing) & i have experience in VB6 and Java, In order to build interface based on this API, I have two option left, Use these dll either from VB or Java.
    As far as I know, calling this DLL in VB requires all the data structures & methods to be declared in VB, I guess which is not the case with Java (? I'm not sure)
    I experiemnted calling these function from Java through JNI, and I successfully did by writting wrapper dll. My question is whether I have to declare all the constants & data structures defined in libpga.h file in java, in order to use them in my java program??
    Any suggesstion would be greatly appreciated,
    Vini

    1. There are generators around that claim to generate suitable wrappers, given some dll input. I suggest you search google. Try JACE, jni, wrapper, generator, .... Also, serach back through this forum, where there have been suggestions made.
    2. In general, you will need to supply wrappers, and if you want to use data from the "C side" in java, then you will need java objects that hold the data.

  • How to create a dll from vi in Labview 7.0 ?

    Hello,
    I want to create a dll from a vi in Labview 7.0.
    I've found the url: http://zone.ni.com/devzone/conceptd.nsf/webmain/003A3E6A5E9CCCEC8625691F0072B2C5
    explaining how to create DLLs from LabVIEW in Labview 6.0i but this method is not available in my Labview 7.0.
    How is it possible to create a dll from a vi or from vi's (stored in llb-files) ?
    With thanks,
             best regards,
                  Geert

    You can only create DLLs and Standalone Applications if you have LabVIEW professional or higher.
    If you only have LabVIEW Base of Full, you need to purchase the Application builder seperately. 
    (Check under "Deployment tools" in the LabVIEW comparison matrix. What level do you have?)
    Message Edited by altenbach on 10-18-2005 08:45 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Transfer class and characteristics data from 3.1i system to ECC 6.0 system

    I have to develop a program to transfer all the classes and characteristics( tcode cl01 and ct04)  in a 3.1i system to an ECC 6.0 system.
    I initially planned to use FMs BAPI_CLASS_GETDETAIL to read from 3.1i and BAPI_CLASS_CREATE to load in ECC 6.0.
    But then I realized that BAPI_CLASS_GETDETAIL does not exist in 3.1i system.
    Could anyone please tell me how to transfer the class and characteristics data from 3.1i to ECC 6.0. What approach and FMs are to be used.
    Thanks,
    Karthik

    Thanks for the reply Madhu.
    We are trying the ALE way, using BD91 and BD92. This way seems to be easier as there is no need to extract data to files.
    IDoc is successfuly sent from the 3.1i system but we are not able to see it in ECC 6.0 system.
    We are checking up the settings.
    Would be very useful if you can provide some more details about the settings to be done.
    Thanks,
    Karthik

  • How to unload dlls?????

    Hi! All,
    I have an applet which copies 3 dlls from the server
    to c drive of the client hard disk. I'm loading one dll by
    calling the method System.load("..."). This loaded library
    inturn loads other two libraries natively in C++ code(in
    JNI_OnLoad function using the LoadLibrary).
    In the stop method of applet I have called a native
    method to unload the dlls which have been natively
    loaded. I'm also able to delete the natively loaded dlls
    from the c drive in the stop method after unloading them
    natively. But I'm not able to unload the dll which has
    been loaded by the method System.load(). Even after I
    close the browser(IE), I'm seeing an instance of IE in the
    process tab of Task manager dialog box.
    Can anybody suggest me how I can unload the dll
    loaded through System.load("..") method and also delete
    it from the hard disk.
    Any comments on this will be of a great help!!!
    Thanx in advance
    Pavana Chandrashekar

    Hi
    I have the same problem too. In my case i cannot unload the dll using native method as the dll and the code that calls it will be a 3rd party stuff. I must be able to dynamically update the class and the dll..
    here is my requirement
    I want to be able to update a class that makes JNI calls dynamically .For this i have a custom classloader.The classloder successfully loads the native library the first time i run the class. On updating the class (i load a new instance of the classloader) i get the error message saying that the native library has already been loaded by another classloader instance. how can i unload the previous instance of the native library so that the update is successful..
    Thanks in advance
    sibi

  • How to Unload Classes?

    i have created custom classloader. now i want to unload classes those are loaded by custom classloader.
    i know that the classes will be unloaded when its classloader is unloaded. so i want to know how to unload cusotm classloader.
    In ClassLoader class there is one static inner class it has unload method . but we can not access that method from custom classloader.

    as a rule of thumb,
    an object of may get marked for gc once no reachable references to it exist in the system.
    a type (class) gets unloaded once:
    1) no reachable references to it exist in the system;
    2) there are no instance of that type left in the system or all the instances are unreachable (which is essencially the same as 1)
    a classloader gets unloaded once there are no reachable references to it exist in the system.
    reachable is the keyword here. Otherwise, if you had two classes A & B references each other, they would never be marked for gc. But as long as no other reference to either A or B exist, they both can be gc'ed. The same applies to classloaders (after all, they are just regular objects). Even though type T holds a reference to its classloader, if nothing refers to T, it's reference to the classloader doesn't count.

  • How to unload DLL in JNI

    How to unload the DLL which is loaded using
    System.loadLibrary()
    namanc

    I got the problem ...
    The java program is abended and the it creates system abend event.
    This is the exact scenario ...
    I have one object which refers the existing the DLL and it also sends very big file to MQ.
    When loading the DLL it is not creating any problem but if i send large file to MQ the java program is abending ...
    I want to know what may be the problem ...
    Is there any memory limit for an object ?
    namanc

  • How do I reference a class in a .dll library?

    How do I reference a class in a .dll library?  The following code extracts the contents of a ListView after a line is MouseDoubleClick:
        static public void GetListViewValues(object sender, List<string> liststListViewValues)
          ListViewItem lvi = sender as ListViewItem;
          ListViewTabs obj = lvi.DataContext as ListViewTabs;
          liststListViewValues.Add(obj.tabNumber);
          liststListViewValues.Add(obj.tabDetails);
        public class ListViewTabs
          public string tabNumber { get; set; }
          public string tabDetails { get; set; }
    I want to move this code (not the class) into a library .dll.  The .dll is generic ... could be called by any namespace.  It needs to know about the ListViewTabs class in this example.
    bhs67

    >>How do I reference a class in a .dll library?
    You add a reference to the .dll (https://msdn.microsoft.com/en-us/library/wkze6zky.aspx?f=255&MSPPError=-2147217396) and add a using statement for the namespace
    in which the class is defined at the top of the code file in which you want to use the class:
    using YourNameSpace;
    >>I want to move this code (not the class) into a .dll.
    The method must be put into some class. You could create a class in the class library and put the method in there:
    namespace YourNameSpace
    public class YourClass
    static public void GetListViewValues(object sender, List<string> liststListViewValues)
    ListViewItem lvi = sender as ListViewItem;
    ListViewTabs obj = lvi.DataContext as ListViewTabs;
    liststListViewValues.Add(obj.tabNumber);
    liststListViewValues.Add(obj.tabDetails);
    public class ListViewTabs
    public string tabNumber { get; set; }
    public string tabDetails { get; set; }
    >>The .dll is generic ... could be called by any namespace.
    Every class belongs to a namespace (potentially the global (or unnamed) namespace) in C#.
    >>It needs to know about the ListViewTabs class in this example.
    If the method in the .dll needs to know about the ListViewTabs class you must put the ListViewTabs class into the same .dll or create another .dll, put the ListViewTabs class there and then add a reference to this .dll from the one containing your method.
    You cannot keep the ListViewTabs class in the WPF application project from which you add a reference to the .dll that contains the method because you cannot add a reference from A to B and from B to A as this will lead to a circular dependency.
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

  • How to convert java class to dll file for using in Microsoft Technology(.n)

    hey hemmj !!!!!!
    nice replying , first of all i d like to say thanks for response me so frequently..... i like such type of guy... i d never forget ur online support.
    hey buddy, i ve a problem with applet application...
    i m working on java chat server build on swing applet. As it is chat server, it is divided into two parts, one is server application and other is client application. I want to run this server app on the client server and the basic thing with this site is that it is running on .net platform(Microsoft). and the other app ll running on the client machine or end user. Now the problem is that this site would run only if the server app ll be run on server. This server app ll open the socket of server, which ll listen the request of the user...... So, the requirement is to convert this java sever class file into dll file and register this dll file with the IIS server.So, It run and stop with the IIS server.
    I ve already search the way to convert the java class file into dll file. This is possible in such way........... below code is for the java class file...
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class chatServer
    public static void main(String args[]) throws Exception
                        ServerSocket sersoc=new ServerSocket(1234);// Any port number above 1000 should do
    // as most ports below 1000 are used by system
    Vector socvec=new Vector();
    String data="";int i,j=0;
    BufferedReader in;
    //System.out.println("Listening of port " + sersoc.getLocalPort());
    //System.out.println("Waiting for connections...");
    while(true)
    Socket soc=sersoc.accept();
    socvec.addElement(soc);
    chatServerReadThread csrt=new chatServerReadThread(socvec, soc);
    in=new BufferedReader(new InputStreamReader(soc.getInputStream()));
    PrintStream out=new PrintStream(soc.getOutputStream());
    out.println("Connected to chat server");
    out.flush();
    data= in.readLine();
    for(i=0;i<socvec.size();i++)
    soc=(Socket)socvec.elementAt(i);
    out=new PrintStream(soc.getOutputStream());
    out.println(data + " connected");
    out.flush();
    //System.out.println(data + " connected");
    csrt.start(); // error is comming from here..... plz help me.
    class chatServerReadThread extends Thread
    Vector socvec;
    PrintStream out;
    chatServerReadThread(Vector socvec, Socket soc)
    this.socvec=socvec;
    try
    out=new PrintStream(soc.getOutputStream());
    }catch(Exception e){}
    public void run()
    try
    String data;
    Socket soc;
    BufferedReader in;
    while(true)
    for(int i=0;i<socvec.size();i++)
    soc=(Socket)socvec.elementAt(i);
    in=new BufferedReader(new InputStreamReader(soc.getInputStream()));
    if(in.ready())
    try
    data=in.readLine();
    if(data.charAt(0) == ']')
    data = in.readLine() + " exited";
    //System.out.println(data);
    socvec.removeElement(soc);
    for(int e=0;e<socvec.size();e++)
    soc=(Socket)socvec.elementAt(e);
    out=new PrintStream(soc.getOutputStream());
    out.println(data);
    out.flush();
    else
    for(int e=0;e<socvec.size();e++)
    soc=(Socket)socvec.elementAt(e);
    out=new PrintStream(soc.getOutputStream());
    out.println(data);
    out.flush();
    }catch(Exception e){socvec.removeElement(soc);}
    }catch(Exception e){e.printStackTrace();}
    first i ve made the jar file of this class
    jar cvf chatServer.jar chatServer.classafter getting the jar chatServer.jar. I ve opened the .net dos prompt and
    type this command which ll make dll file automatically....
    > jbimp /t:library chatServer.jar
    And you'll see the following output:
    Microsoft (R) Java-language bytecode to MSIL converter version 1.1.4322.0
    for Microsoft (R) .NET Framework version 1.1.4322
    Copyright (C) Microsoft Corp 2000-2002. All rights reserved.
    Created chatServer.dll
    I cant get the problem origin from where it is comming, when i tried to convert it into .dll file it shown an error that, it did not recongnized the method in first class
    public static void chatServerReadThread.start() method
    is not recognized by .net dos prompt commnad. But when i omit this method it gets created the .dll file. This start method is basically the default method of thread class that run the thread from the same class..
    By vewing the code u can visulize the thing,, i ve marked the code from where the error is comming.
    Plz do it as soon as possible, i ll waiting for ur reply......
    I ll be really thanking u for that....
    Thanx and regards
    Niraj Kumar Singh

    I wonder if this will work:
    jbimp /t:exe chatServer.jar
    Your chatServer is an application that can be started from the commandline.
    A dll is a library to be used in com, com+, other executables or ....

  • How to convert .class file to .dll file

    hi,
    I got a problem, I have to convert my java .class file to .dll file. Microsoft VC++ program will invoke the converted .dll file.
    Is there any other possibility.
    I was confused.
    Cam any body help me. If you are having solution for the can you send to my [email protected] account.
    thanks,

    No, it is not possible to do what you are suggesting. Yes, you could produce a DLL that wraps the JVM and loads your java class exposing a C and/or C++ callable interface, but that is a lot to go through unless your class is VERY complex. Otherwise, you might want to just create and maintain two implementations.

Maybe you are looking for

  • How do I transfer iTunes from a pc to an iMac?

    I have a dell laptop and I want to transfer my iTunes from that laptop to my iMac. What's the best way?

  • Internal order's profit center overrides FI document profit center

    Dear all, I have a problem in posting FI document. here is the situation. 1.the company create statistical IO as jobs to see performance by jobs. 2.when receive money from customer. accountant post FI doc. ref to stat IO and manually judge how much t

  • Determine usb port

    Hi, I have a problem with this configuration: How can I determine which USB 6210 device is on USB 1 together with the USB to RS485 converter? I communicate with the converter via CreateFile(). thanx!! Solved! Go to Solution.

  • This is a minsweeper in java but......

    The programme runs(thank god) but if you try to be fast, the buttons doesn't correspond in time...like every button you press you have to wait 2 secs before pressing a button again. Why that happens?what's my code problem? Here is my code... //first

  • Forgot admin. password

    My grandfather bought me my computer for college and set it up for me...only he set me up as the admin. and then didn't tell me the password and he forgot it...is there anything that can be done so that I can reset my password?