Apologies for posting yet another Java jar question. I did have a look at the existing similar questions, but still haven’t managed to get an Example class running using advices found in existing answers.
Here’s what I tried so far:
george-profenzas-macbook:src george$ ls
Example.java org
george-profenzas-macbook:src george$ javac -cp $CLASSPATH Example.java
george-profenzas-macbook:src george$ ls
Example$1.class Example$2.class Example$3.class Example.class Example.java org
george-profenzas-macbook:src george$ java -cp $CLASSPATH Example
Exception in thread "main" java.lang.UnsatisfiedLinkError: no OpenKinect in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.openkinect.Context.<clinit>(Context.java:43)
at Example.main(Example.java:52)
george-profenzas-macbook:src george$ echo $CLASSPATH
/Users/george/Downloads/shiffman-libfreenect-2e0f185/wrappers/java/dist/OpenKinect.jar:.
Looks like it didn’t find the path to OpenKinect. I tried copying the jar in the same folder(cp ../../dist/OpenKinect.jar) then tried running Example again:
george-profenzas-macbook:src george$ java -cp OpenKinect.jar Example
Exception in thread "main" java.lang.NoClassDefFoundError: Example
Caused by: java.lang.ClassNotFoundException: Example
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Now it seems it didn’t find the path to Example, so I assume the . in $CLASSPATH didn’t work and I don’t know why.
I kept playing with -cp back and forth but java says “no!”:
george-profenzas-macbook:src george$ java -cp "OpenKinect.jar:./Example.java" Example
Exception in thread "main" java.lang.NoClassDefFoundError: Example
Caused by: java.lang.ClassNotFoundException: Example
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
george-profenzas-macbook:src george$ java -cp "OpenKinect.jar:." Example
Exception in thread "main" java.lang.UnsatisfiedLinkError: no OpenKinect in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.openkinect.Context.<clinit>(Context.java:43)
at Example.main(Example.java:52)
george-profenzas-macbook:src george$ java -cp .:OpenKinect.jar Example
Exception in thread "main" java.lang.UnsatisfiedLinkError: no OpenKinect in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.openkinect.Context.<clinit>(Context.java:43)
at Example.main(Example.java:52)
It seems that it either finds the path to the jar, but not to Example or the other way around and I’m running around in circles.
I set the java path to point to 1.6 64bit, so java -version prints:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03-384-10M3425)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02-384, mixed mode)
and I even copied the jar to /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes and jnilib to /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Libraries, but no joy.
Any tips ?
What you have here is a misunderstanding of the error message. There is a difference between the classpath and the library path. While you got the classpath correct with the jar and the dot for the current directory, you do not specify the path to where the native parts of the Kinect SDK are.
You do so by adding
I do not know the OpenKinect structure, but often it is some kind of “bin” or “native” directory.
To clarify: this is the path where OpenKinect.dll (for Windows) or libOpenKinect.so (Linux and friends) etc. are located.
See http://openkinect.org/wiki/Java_JNI_Wrapper at the very bottom of the page.