• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading/Unloading Libraries at Runtime  RSS feed

 
Fahd Shariff
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about loading different versions of a library dynamically at runtime.

I have two version of an external C library:

/programs/app_v1
/programs/app_v2

Currently, in my java app startup script I either:

export LD_LIBRARY_PATH=/programs/app_v1
or
export LD_LIBRARY_PATH=/programs/app_v2

depending on what version of the library I wish to load.

My question is: can I dynamically load app_v1 or app_v2 at runtime based on a user's request?
Essentially I would like to be able to switch versions without having to restart my java application.

Any help would be appreciated.

Thanks
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you use the java.library.path System property, rather than LD_LIBARARY_PATH, to tell the JVM where your native libraries are? If so, does changing its value during the program's execution change where it looks for native libraries?

(I don't know and checking would take longer than I have available. I am just guessing, in case it helps you.)
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and I don't think there's any way to unload a native library explicitly, once loaded. Not from Java anyway.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!