Vivekanand Vivekanand - 7 months ago 201
Java Question

UnsatisfiedLinkError in exported (Eclipse) executable jar file

The code works fine when executing from Eclipse. I'm using OpenCV 2.4.11 and JavaFX for UI. When I export an Executable Jar from Eclipse and run it from cmd I get the following exception:

enter image description here

I followed many post here on SO and OpenCV forum(1, 2, 3, 4) but, none of the answers seems to help me.

I have added the OpenCV jar as library and Native Library is linked to /build/java/x64 as suggested in SO answers.

Java Build path

The exception occurs at the System.loadLibrary(Core.Native_Library_Name), I checked the Native_Library_Name and the OpenCV version is same as the one I imported in my project.

public class CustomFrame extends Application{

@Override
public void start(Stage primaryStage){
Group root = new Group();
Canvas canvas = new Canvas(1440, 840);

ImageView imageView = new ImageView();
imageView.setFitHeight(canvas.getHeight());
imageView.setFitWidth(canvas.getWidth());
new FrameController().startCamera(imageView);

root.getChildren().addAll(imageView, canvas);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}

public static void main(String[] args)
{
// load the native OpenCV library
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
launch(args);
}
}


If anybody thinks that I have missed something please do let me know.

Answer

It looks like you need to add the path containing the opencv-2411 native libraries to the -Djava.library.path when running from the command prompt.

So something like this:

java -Djava.library.path="C:\Opencv2.1.11\opencv\build\java\x64" -jar BlurDetector.jar
Comments