简体   繁体   中英

Java JNI: How to load library multiple times?

I am trying to load the same library file using System.loadLibrary or System.load. The reason I do this is because they are the same code but different configuration. I want those 2 library files to have its own world without affecting each other. (If I change the value at left side, it's not going to change the right side) Is this doable? Or is Java going going to ignore my second System.loadLibrary call since it's already loaded?

--------------------------
|          Java          |
--------------------------
      |            |
      v            v
  libTst.so    libTst.so
      |            |
      v            v
   libA.so      libA.so

Or is Java going going to ignore my second System.loadLibrary call since it's already loaded?

The operating system is going to ignore it. You'll have to provide it twice under two names.

i'm not sure but i think there are two ways: 1-change the secondary lib name and changes name in your code when to use . 2-change the root of lib (you can insert your lib in jvm lib root) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM