Ask Your Question
1

Error when lunching the runnable jar file

asked 2015-08-23 09:05:02 -0600

Seriusam gravatar image

Hi, I'm trying to export an application that uses openCV 3 library and works completely fine on eclipse. I've done all these native library things. But, when I try to execute the exported file I get this error.

http://postimg.org/image/4ivynuaer/

According to my researches this error is about the dll files. But, I couldn't figure out how to fix it. Could you please help me.

Thank you.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-09-20 01:06:10 -0600

RolandC gravatar image

You are missing the opencv_java300.dll in your library path. You could either specify its location by using -Djava.library.path=... when you start the program or you could use this piece of code in your main method:

    System.setProperty("java.library.path", ".");

    Field fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
    fieldSysPath.setAccessible( true );
    fieldSysPath.set( null, null );

The problem with the build path in eclipse is that you need to use an absolute path for the native library location. Nobody wants that. With the code above you remap the library path to a relative path, so when you copy your project or rename it, you don't have to mess around with the build path settings. Your code would still work.

The "." means that in your created jar the dlls must be in the same folder as the jar. You could of course use a sub-folder, eg ./lib/x64. Then you need to have the libraries in that sub-folder in both eclipse and your jar's location.

edit flag offensive delete link more
0

answered 2016-12-30 21:52:32 -0600

If you work on Windows OS, then copy "opencv_java2413.dll" to "C:\Windows\System32". This .dll file is located in your OpenCV installed file.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-23 09:05:02 -0600

Seen: 1,309 times

Last updated: Sep 20 '15