JDK-4280189 : loadLibrary() fails to load a shared lib whose path is in java.library.path
  • Type: Bug
  • Status: Closed
  • Resolution: Not an Issue
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P3
  • Affected Version: 1.2.1
  • OS: solaris_7
  • CPU: generic
  • Submit Date: 1999-10-12
  • Updated Date: 2012-11-02
  • Resolved Date: 1999-10-13
Description
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 " +
                         System.getProperty("java.library.path"));
      System.loadLibrary("SdrcDxfLoader");
   }

The output looks like this:
SUN82:/scratch/gemeyer/ms7/src/DXF:160$ java DxfLoader
Library Path is
/usr/java/bin/../jre/lib/sparc:/scratch/gemeyer/ms7/src/DXF
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.UnsatisfiedLinkError.<init>(UnsatisfiedLinkError.java:42)
        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?


Comments
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.
2004-06-11