Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UnsatisfiedLinkError using JNI for Native C Package libfprint

I am trying to use a package in my final year project called libfprint. This is an opensource fingerprint reader SDK. I am doing my project in Java so I need to port over the libfprint functionality.

A stroke of good luck hit me and turned out somebody already did this. A package called jlibfprint is a JNI wrapper for libfprint.

So I followed the instructions in both jlibfprint and libfprint for setup. libfprint more or less works fine. As for jlibfprint, when I tried to run the sample program I got,

Exception in thread "main" java.lang.UnsatisfiedLinkError: no JlibFprint_jni in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
    at java.lang.Runtime.loadLibrary0(Runtime.java:840)
    at java.lang.System.loadLibrary(System.java:1047)
    at JlibFprint.<clinit>(JlibFprint.java:28)
    at SampleRun.main(SampleRun.java:30)

JlibFprint.(JlibFprint.java:28)

is referring to

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

So now I'm looking through the project properties and get to the field "Native library location", and I point it to the directory containing a single file called libJlibFprint_jni.so.

Now when I run the program, the error I get is,

Exception in thread "main" java.lang.UnsatisfiedLinkError: JlibFprint.enroll_finger()LJlibFprint$fp_print_data;
    at JlibFprint.enroll_finger(Native Method)
    at SampleRun.main(SampleRun.java:36)
Enroll the first finger...

Here are the sample Java file

SampleRun.java

public class SampleRun {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        JlibFprint jlibfprint = new JlibFprint();
        JlibFprint.fp_print_data pd1, pd2;
        int matchValue;
        try
        {
            System.out.println("Enroll the first finger...");
            pd1 = jlibfprint.enroll_finger();
            System.out.println("Compare the previous acquisition with the next one...");
            pd2 = jlibfprint.enroll_finger();
            matchValue = JlibFprint.img_compare_print_data(pd1, pd2);

            System.out.println(matchValue);
            if (matchValue > JlibFprint.BOZORTH_THRESHOLD)
            {
                System.out.println("[OK] The two fingerprints are compatible!");
            }
            else
            {
                System.out.println("[FAIL] The two fingerprints are not compatible!");
            }
        }
        catch (JlibFprint.EnrollException e)
        {
            System.err.format("Enroll Exception [%d]\n", e.enroll_exception);
            e.printStackTrace();
        }
    }
}

I am using Ubuntu 11.10 with Eclipse Juno.

Anybody with a breeze of knowledge in this area would be a great help !

like image 400
TomSelleck Avatar asked Dec 29 '25 03:12

TomSelleck


1 Answers

I know this is a bit late. But if you are using the eclipse for your java project then go to the Run Configurations and then go to the Arguments tab.

In the VM arguments add following line:

-Djava.library.path="${workspace_loc}/PROJECT_NAME/DIRECTORY_NAME_CONTAINIG_LIBRARY:${env_var:PATH}"
like image 112
code_fish Avatar answered Dec 31 '25 15:12

code_fish