Error with using OpenCV for processing in jar file.

edited April 2016 in Kinect

Hello everyone

When I'm running my application from eclipse I don't have any problems, but when I'm trying to run it as JAR runnable file exported form Eclipse I have following error:

http://screenshot.sh/ofjVYNTW9VBaO

The problem is in this method:

private String getLibPath() {
        URL url = this.getClass().getResource("OpenCV.class");
        if (url != null) {
          // Convert URL to string, taking care of spaces represented by the "%20"
          // string.
          String path = url.toString().replace("%20", " ");
          int n0 = path.indexOf('/');

          int n1 = -1;


          n1 = path.indexOf("opencv_processing.jar");
          if (PApplet.platform == PConstants.WINDOWS) { //platform Windows
            // In Windows, path string starts with "jar file/C:/..."
            // so the substring up to the first / is removed.
            n0++;
          }


          if ((-1 < n0) && (-1 < n1)) {
            return path.substring(n0, n1);
          } else {
            return "";
          }
        }
        return "";
      }

Anyone know how to solve this problem?

Thanks for help

Answers

  • I temporary solved problem by making a jar file with option ""Copy required libraries into a sub-folder next to the generated JAR".

    Before I used "Package required libraries into generated JAR"

Sign In or Register to comment.