i can't used cmd to run java -jar My Application

asked 2019-03-07 00:30:54 -0600

C:\Users\Chin\Documents\NetBeansProjects\JavaFXApplication4>java -jar JavaFXApplication4.jar

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)

Caused by: java.lang.UnsatisfiedLinkError: no opencv_java401 in java.library.path
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.loadLibrary0(Unknown Source)
    at java.lang.System.loadLibrary(Unknown Source)
    at javafxapplication4.JavaFXApplication4.main(JavaFXApplication4.java:49)
    ... 11 more

Exception running application javafxapplication4.JavaFXApplication4

But my code compile in net bean it work

public class JavaFXApplication4 extends Application {

private static String pathopencv;

@Override
public void start(Stage primaryStage) {
    System.setProperty("java.net.useSystemProxies", "true");
    ImageView live = new ImageView();
    threadCV1 cv = new threadCV1();
    //
    cv.opencvmera(pathopencv, live, 800, 600);

    StackPane root = new StackPane();
    root.getChildren().add(live);

    Scene scene = new Scene(root, 800, 600);

    primaryStage.setTitle("live Stream Link " + pathopencv);
    primaryStage.setScene(scene);
    primaryStage.show();

}

/**
 * @Param args the command line arguments
 */
public static void main(String[] args) {
   System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    System.load("C:\\opencv\\build\\bin\\opencv_ffmpeg401_64.dll");
    pathopencv = "rtsp://admin:[email protected]:554/Streaming/Channels/101/";
    System.out.println("pathopencv +++"+pathopencv);
    launch(args);
}}

And i set native library project properties>>run>>VM options is -Djava.library.path="C:\opencv\build\java\x64"

Anything wrong! thank you sir for suggestion

edit retag flag offensive close merge delete

Comments

you unfortunately don't show the code for the non-working version, so how can we help ?

System.load("C:\\opencv\\build\\bin\\opencv_ffmpeg401_64.dll");

no, you don't have to load this, it (the folder containing it) has to go on the PATH environment var instead

berak gravatar imageberak ( 2019-03-07 03:08:57 -0600 )edit