Skip to content
Advertisement

How to know the path of a native library that JVM loaded?

Assume a Java source code uses System.loadLibrary("lib-name") to load a library lib-name. Further, assume that multiple copies of lib-name exist throughout the system.

Question: is there a way to know the path of the lib-name that the jvm loaded? I’m looking for something like -verbose:class.

Thanks.

Advertisement

Answer

On Unix style OS the fully qualified paths for libraries should be visible in lsof | grep {yourjvmpid}.

The lsof output will print a lot of information on open file handles – it is also very helpful to track bad resource handling in application code – and with suitable additional | grep you should narrow down the information for various .so files or the library path you are searching for.

Use jps or ps -ef to track down the appropriate pid.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement