简体   繁体   English

Java JNI:如何多次加载库?

[英]Java JNI: How to load library multiple times?

I am trying to load the same library file using System.loadLibrary or System.load. 我正在尝试使用System.loadLibrary或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是否会忽略我的第二个System.loadLibrary调用,因为它已经加载了?

--------------------------
|          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? 或者Java是否会忽略我的第二个System.loadLibrary调用,因为它已经加载了?

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 . 我不确定,但我认为有两种方法:1 - 更改辅助lib名称并更改代码中的名称何时使用。 2-change the root of lib (you can insert your lib in jvm lib root) . 2 - 更改lib的根目录(可以在jvm lib root中插入lib)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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