FIX: MSJAVAH Fatal Error: java.lang.UnsatisfiedLinkError (222581)



The information in this article applies to:

  • Microsoft SDK for Java 3.1
  • Microsoft virtual machine

This article was previously published under Q222581

SYMPTOMS

When running MSJAVAH on a compiled Java class, the following error appears:
Fatal error: java.lang.UnsatisfiedLinkError: no myDLL in shared library path

CAUSE

In the 29xx series of the Microsoft virtual machine (Microsoft VM), MSJAVAH never wants to initialize the specified class. In the 31xx series, it always wants to initialize the specified class if the class contains primitive members that are declared static and final. Under these conditions, the static block containing the System.loadLibrary( ) method is executed and the aforementioned error occurs.

RESOLUTION

You can use one of the following to resolve this problem:
  • Use SDK for Java Version 3.2 or later. You can download this from http://www.microsoft.com/mscorp/java. This includes a version of MSJAVAH that doesn't ignore the -NOCLINIT command line switch. The -NOCLINIT option tells MSJAVAH not to run static initializers.
  • Comment out the System.loadLibrary( ) line before running MSJAVAH.
  • Use a PC with the earlier 29xx series Microsoft VM to generate your headers.
  • If you created the DLL before upgrading to SDK For Java 3.1, do not delete the DLL. If MSJAVAH can find it, it won't complain.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This problem was corrected in Microsoft SDK for Java version 3.2 for Windows.

MORE INFORMATION

To reproduce this error, make sure that you are using SDK for Java 3.1 and compile the following source. Then run MSJAVAH on the resulting class file.
public class TestMSJAVAH {
  public native void myNativeMethod();

  // this is the culprit:
  public static final double A=3.1;

  // these work fine:
  public static double B=3.2;
  public final  double C=3.3;

  // and this is OK, too:
  public static final Double D=new Double(3.4);

  static {
    System.loadLibrary("myDLL");
  }

  public static void main(String args[]){
    new TestMSJAVAH().myNativeMethod();
  }
}
				

Modification Type:MinorLast Reviewed:11/14/2005
Keywords:kbbug kbfix kbJNative KB222581