1

To my understanding, java.library.path sets the .so or .dll native library for JVM. If we want to tell JVM the our java file jar path, we can use -classpath.

I happened to see an service which uses java.library.path and that path contains many java jars such as -Djava.library.path=:/env/service/lib. And /env/service/lib contains the services dependency java jar files. So my questions is: if we sets the java.library.path to a a folder containing dependency java jar files, does JVM classloader recognize them?

hongchangfirst
  • 245
  • 3
  • 17

1 Answers1

0

The JVM classloader typically only uses the classpath. It doesn't use other paths. e.g the PATH for finding commands.

The PATH, the java.library.path and classpath can all use the same directory, or not.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • Do you happen to know what does this mean? "-Djava.library.path=:/env/service/lib". Notice that there's a colon, and the left of the colon is blank. Is this the same as "-Djava.library.path=/env/service/lib"? – hongchangfirst May 14 '18 at 02:32
  • @hongchangfirst I assume it means to also look in the current directory. Using a `.` would be clearer. – Peter Lawrey May 14 '18 at 07:07