Am using -Xbootclasspath to add my custom jars, But this prevents loading custom JNI libraries from my user directory. Is there a work around?

Davanum Srinivas

That is the intended behavior. All system classes will only lookup shared libraries in $JAVA_HOME/bin. If you do need to load custom libraries for the system classes, there are several choices.

  • Install custom libraries into $JAVA_HOME/bin;
  • Set the property sun.boot.library.path to include the user library path.
    The syntax is
    java -Dsun.boot.library.path=$JAVA_HOME/bin:$CUSTOM/bin ...
NOTE: Put classes into boolclasspath is highly risky. In the future, the vm may apply strict rules on system classes. These workaround may not work in the future. Updating the user code to avoid relying on bootclasspath is wise approach.