JavaFX and maven: NullPointerException: Location is required

后端 未结 6 1952
别跟我提以往
别跟我提以往 2020-11-28 07:03

I have been trying to get Maven set up with JavaFX. Even though I was unexperienced with Maven and JavaFX, I didn\'t expect it to be so much of a challenge. My Java knowledg

6条回答
  •  执笔经年
    2020-11-28 07:50

    For me I had took care of following things -

    1. Make sure fxml file is placed where your main class resides. And then load it using this - (In my case, TechJFX.fxml is the file)

      FXMLLoader loader = new FXMLLoader(getClass().getResource("TechJFX.fxml"));
      
    2. Add opencv-*.jar to your project folder (In my case opencv-300.jar)

    3. Add the jar to the build path using

    Right click on the project folder -> Build Path -> Configure Build Path -> Libraries Tab -> Add External JARS and locate the jar

    Also, under Order and Export -> Tick opencv-300.jar and JRE System Library(if not already ticked)

    1. Copy opencv_java*.dll (In my case opencv_java300.dll) to the same location where you jar is in the project folder.

    2. Add the following method to your main class

       static{ 
              System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
         }
      
    3. Done.

    Hope this helps someone facing similar issue.

提交回复
热议问题