Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Load native library in application context and unload/load with application  RSS feed

Ganesha Duggirala
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm currently using System.loadLibrary in a static block to load a native c++ library. However, if i redeploy my web app that loads this library, i get unsatisfiedlink error since the redeployed app tries to load the native library again during the JNI call and fails since the library is already loaded in memory.

Is there any way to load the library specific only to the web application in the application context and not the system context? I basically want the library to be unloaded when i undeploy or redeploy the web application. I do not want the library to be available to any other application other than mine (I know some of you will say that this defeats the purpose of having a library and load it only in a particular application context but that's what I need to do) and hence i want it to be available as part of my web application.

Also where can i place the native library under my application path so that it can be accessed by my application and not particularly via one of the directories in LD_LIBRARY_PATH? In WEB-INF folder or some other folder?

Ulf Dittmer
Posts: 42972
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!