Prevent Java from loading library more than once

前端 未结 4 889
猫巷女王i
猫巷女王i 2020-12-15 22:06

I have several classes that use the same JNI library, called \"jni\". In each of those classes, I have a System.loadLibrary() call in the class\'s static initializer:

<
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 23:00

    Create a singleton class which load "jni" only during it's first instantiation, and call this singleton in class1 and class2 instead of System.loadLibrary("jni")

提交回复
热议问题