[Q] unLoadLibrary ?

Discussion in 'Java' started by obladi, Jun 15, 2004.

  1. obladi

    obladi Guest

    Hi. I'm using DLL through JNI. However, when I got an Exception before
    calling the DLL library, there is a "java.lang.UnsatisfiedLinkError: xxx.dll
    already loaded in another classloader". Of course, it wokrs perfectly when
    there is no Exception. How can I get this stuff work fine? Is there any
    method something like "unloadLibrary" ? ;)
     
    obladi, Jun 15, 2004
    #1
    1. Advertising

  2. In article <>,
    (obladi) wrote:

    >:Hi. I'm using DLL through JNI. However, when I got an Exception before
    >:calling the DLL library, there is a "java.lang.UnsatisfiedLinkError: xxx.dll
    >:already loaded in another classloader". Of course, it wokrs perfectly when
    >:there is no Exception. How can I get this stuff work fine? Is there any
    >:method something like "unloadLibrary" ? ;)


    There is no explicit way I know of to unload a library. But there may
    be some alternatives.

    This is purely speculation, as the library loaded in my app is in a
    class that's going to exist for the life of the app. But it occurs to
    wonder if the library would get unloaded when the class is garbage
    collected. I have no idea whether that's true or not -- just a thought.

    The other thought is to simply set a boolean someplace (perhaps a static
    member variable in some class you can access from everywhere) indicating
    that it's been loaded and thus prevent attempts from elsewhere.

    = Steve =
    --
    Steve W. Jackson
    Montgomery, Alabama
     
    Steve W. Jackson, Jun 16, 2004
    #2
    1. Advertising

  3. obladi

    Roedy Green Guest

    On Wed, 16 Jun 2004 15:06:25 -0500, "Steve W. Jackson"
    <> wrote or quoted :

    >The other thought is to simply set a boolean someplace (perhaps a static
    >member variable in some class you can access from everywhere) indicating
    >that it's been loaded and thus prevent attempts from elsewhere.


    you could also do the loadLibrary in a static init block.
    Then it will get called only once.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jun 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page