JDK-4280189 : loadLibrary() fails to load a shared lib whose path is in java.library.path
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.2.1
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_7
  • CPU: generic
  • Submitted: 1999-10-12
  • Updated: 2012-11-02
  • Resolved: 1999-10-13
System.loadLibrary() cannot load a shared library, even if the java.library.path is specified correctly, containing a path to the shared library. The following is a code sequence:

   static {
      String scPath = System.getProperty("java.library.path");
      scPath = scPath.concat(":/scratch/gemeyer/ms7/src/DXF");
      System.setProperty("java.library.path", scPath );
      System.out.println("Library Path is " +

The output looks like this:
SUN82:/scratch/gemeyer/ms7/src/DXF:160$ java DxfLoader
Library Path is
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
SdrcDxfLoader in java.library.path
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.<init>(Throwable.java:94)
        at java.lang.Error.<init>(Error.java:50)
        at java.lang.LinkageError.<init>(LinkageError.java:43)
        at java.lang.ClassLoader.loadLibrary(Compiled Code)
        at java.lang.Runtime.loadLibrary0(Runtime.java:471)
        at java.lang.System.loadLibrary(System.java:745)
        at <Unloaded Method>

If LD_LIBRARY_PATH is set, the program works.

Is this a usage problem or bug?

EVALUATION Sorry, this just isn't supposed to work that way. Like most System properties, java.library.path is intended to be read-only. We need to document this better.