Wednesday, October 23, 2013

Resolving Unsatisfied link error in OpenNI java on Windows

If you are getting any of the following error while trying to Run OpenNI on a windows PC, follow the below steps to rid of the errors (I am assuming you are using Eclipse)

java.lang.UnsatisfiedLinkError: C:\Program Files\OpenNI2\Redist\OpenNI2.jni.dll: Can't find dependent libraries

or

java.lang.UnsatisfiedLinkError: no OpenNI2.jni in java.library.path



I am also assuming you have installed OpenNI2 in the folder C:\Program Files\OpenNI2

  • Make sure you have org.openni.jar in your project and added to your build path
  • Then got Run -> Run Configurations and choose the tab named "Arguments"
  • In the section "VM Arguments" add the below entry  
                   -Djava.library.path=C:\Progra~1\OpenNI2\Redist\

  • Now we have to load the dll manually as below
 try {
   System.load("C:\\Program Files\\OpenNI2\\Tools\\OpenNI2.dll");
    ...
                         .. your remaining code here
                         ..
   OpenNI.shutdown();
  } catch (Exception e) {
   e.printStackTrace();
  }

Blog Archive