From: QA QA <qa2...@gm...> - 2010-06-02 19:02:45
|
Hi, I used the 'simple' example wrapped in swig package for testing. I got 3 java files after doing 'swig -java example.c', runme.java example.java exampleJNI.java and have the library successfully compiled. I could run 'java runme' without any problem. However, when I added package path in each of the 3 java files, say 'package com.A.test', I encountered errors like: Exception in thread "main" java.lang.UnsatisfiedLinkError: com.A.test.exampleJNI.gcd(II)I at com.yahoo.yos.apt.quality_classifier.tmp.exampleJNI.gcd(Native Method) at com.yahoo.yos.apt.quality_classifier.tmp.example.gcd(example.java:14) at com.yahoo.yos.apt.quality_classifier.tmp.runme.main(runme.java:20) Any idea what the error could be? Many thanks. Below is the code of 3 java files: runme.java ========= package com.A.test; public class runme { static { try { System.load("/tmp/libnewexample.so"); } catch (UnsatisfiedLinkError e) { System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help. \n" + e); System.exit(1); } } public static void main(String argv[]) { // Call our gcd() function int x = 42; int y = 105; int g = example.gcd(x,y); System.out.println("The gcd of " + x + " and " + y + " is " + g); } } example.java ========== package com.A.test; /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 1.3.29 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ public class example { public static int gcd(int x, int y) { return exampleJNI.gcd(x, y); } public static void setFoo(double value) { exampleJNI.Foo_set(value); } public static double getFoo() { return exampleJNI.Foo_get(); } } exampleJNI.java ============= package com.A.test; class exampleJNI { public final static native int gcd(int jarg1, int jarg2); public final static native void Foo_set(double jarg1); public final static native double Foo_get(); } |