JNI : Two native libraries with the same functions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • floca77
    New Member
    • Feb 2008
    • 2

    JNI : Two native libraries with the same functions

    Hello,

    I have two versions of the same native library like "abc_v1.sl" and "abc_v2.sl" .
    They have the same functions but they act differently.

    I want to use both of them in parallel (each in its own thread) but only the functions of the first loaded library are being called.

    Isn't there any possibility to load each native library in a different name space... maybe a different JVM?

    Any help will be appriciated.
    Thank you!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by floca77
    Hello,

    I have two versions of the same native library like "abc_v1.sl" and "abc_v2.sl" .
    They have the same functions but they act differently.

    I want to use both of them in parallel (each in its own thread) but only the functions of the first loaded library are being called.

    Isn't there any possibility to load each native library in a different name space... maybe a different JVM?

    Any help will be appriciated.
    Thank you!
    I don't think that's possible. If they have the same name then you are probably getting a name clash.

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      Originally posted by floca77
      Hello,

      I have two versions of the same native library like "abc_v1.sl" and "abc_v2.sl" .
      They have the same functions but they act differently.

      I want to use both of them in parallel (each in its own thread) but only the functions of the first loaded library are being called.

      Isn't there any possibility to load each native library in a different name space... maybe a different JVM?

      Any help will be appriciated.
      Thank you!
      Well, different JVM implies different processes, so then anything is possible.

      I believe that within one JVM, having different class loaders may allow you to load these libraries. The separate class loaders will keep them apart.

      Comment

      • floca77
        New Member
        • Feb 2008
        • 2

        #4
        Originally posted by BigDaddyLH
        Well, different JVM implies different processes, so then anything is possible.

        I believe that within one JVM, having different class loaders may allow you to load these libraries. The separate class loaders will keep them apart.
        Can you give me an example on how to use class loaders in this situation ?

        'Cause the native libraries are just loaded into memory using
        Code:
        System.load([I]<libraryName>[/I]);
        and I don't have any possibility to keep them apart.

        Thanks again!

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by floca77
          Can you give me an example on how to use class loaders in this situation ?

          'Cause the native libraries are just loaded into memory using
          Code:
          System.load([I]<libraryName>[/I]);
          and I don't have any possibility to keep them apart.

          Thanks again!
          Try using a URLClassLoader and then, in the class you've loaded try using System.load and see which ClassLoader gets used. No guarantees, but it's worth a try.

          Comment

          Working...