Default Java library path?

℡╲_俬逩灬. 提交于 2019-11-27 01:46:41

问题


I understand that you can set the Java library path with an option (-Djava.library.path=/path/to/libs) before executing the program, but is there a place on the system where Java looks if you don't set it manually?


回答1:


Its default value depends on the operating system:

  • On Windows, it maps to PATH
  • On Linux, it maps to LD_LIBRARY_PATH
  • On OS X, it maps to DYLD_LIBRARY_PATH



回答2:


However, Matt Ball is not totally correct.

On my Linux box, my Java library path is

/usr/lib64/icedtea6/jre/lib/amd64/server:/usr/lib64/icedtea6/jre/lib/amd6ib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

While my LD_LIBRARY_PATH is /usr/local/lib64.




回答3:


For Java 8, this differs based on OS. This is the behavior I observed:

  • Windows 10/Oracle JDK 8: java.library.path=%PATH%;.
  • macOS El Capitan/Oracle JDK 8: java.library.path=$JAVA_LIBRARY_PATH:~/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.. DYLD_LIBRARY_PATH and LD_LIBRARY_PATH variables are ignored. Moreover, both these variables are removed from the environment of Java applications.
  • Linux CentOS 7/Open JDK 8: java.library.path=$LD_LIBRARY_PATH:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib


来源:https://stackoverflow.com/questions/20038789/default-java-library-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!