Vivekanand Vivekanand - 2 years ago 440
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{

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

ImageView imageView = new ImageView();
new FrameController().startCamera(imageView);

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

public static void main(String[] args)
// load the native OpenCV library

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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download