Ask Your Question
0

How to export a .jar file that uses openCV with eclipse?

asked 2013-10-29 13:54:26 -0600

Max Muster gravatar image

updated 2013-10-29 13:59:29 -0600

Hello there.

I have been writing java application in eclipse for some time. It creates a frame and displays some images from the webcam on it. Also it does some image processing with openCV-methods.

The application works fine in eclipse, but now i wanted to export it as a .jar file.

So i did what i always did: File > Export > Runnable JAR file. Then i selected my launch configuration (class with main method) and had to choose one of those options: image description

when i try to run my exported .jar now, nothing happens, no frame comes up. i have tried each of the three options above and none solved the problem.

in my project i have added the openCV-jar as userlibrary and in my main class i load it like this: System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

so summary: how do i correctly export a .jar file that uses openCV?

@StevenPuttemans i saw you responded to a similar question once, do you maybe have a solution?

edit retag flag offensive close merge delete

Comments

I have no idea :) Probably I did a google search on my previous answer. Could it be that you have to link your openCV libraries as static libraries, so that the sourcecode gets included into your jar file? Just a guess...

StevenPuttemans gravatar imageStevenPuttemans ( 2013-10-30 03:22:56 -0600 )edit
1

@StevenPuttemans thanks for you reply mate :) http://scr.hu/1gyz/ij1p3 this is how my project structure looks like, the opencv jar and the opencv dll are in my project in ecplise. can you explain that "static libraries" aproach? i dont know how that wokrs, sorry :) also, when i export my app now and start it from the commandline with "java -jar myopencvtest.jar" then i get the following exception: http://scr.hu/1gyz/i4ceb from what i found out, this exception come up when the opencv.jar can't find its needed opencv_java246.dll. so what i tried was to put the opencv_java246.dll in my JRE bin folder, and there you go, the exported jar works just fine. though putting the dll in the local JRE bin folder is not a solution if i want to use the jar on different computers. there must be an easier

Max Muster gravatar imageMax Muster ( 2013-10-30 13:52:21 -0600 )edit

...way to bind the opencv_java246.dll with the exported jar, right?

Max Muster gravatar imageMax Muster ( 2013-10-30 13:53:09 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2013-10-31 07:14:19 -0600

Ok static libraries is the principle where you add the actual code of the different openCV functions into your jar, instead of depending on the supplied dll's that need to be on the correct location in your system setup. I know how it works for C++ projects, but I have no idea if the Java interface even supports the use of static libraries...

In the Java introduction, I found the following quote:

When OpenCV is built as a set of static libraries (-DBUILD_SHARED_LIBS=OFF option) the Java bindings dynamic library is all-sufficient, i.e. doesn’t depend on other OpenCV libs, but includes all the OpenCV code inside.

So I guess you need to manually built openCV on your system, using the shared libs paramerer) to reach this openCV independent approach.

edit flag offensive delete link more

Comments

1

alright, sounds promising, i guess i will try that :) thanks for your effort. i will mark your answer as correct if this way is working :)

Max Muster gravatar imageMax Muster ( 2013-10-31 07:55:46 -0600 )edit

Good luck with the tryout!

StevenPuttemans gravatar imageStevenPuttemans ( 2013-10-31 08:15:11 -0600 )edit

Question Tools

Stats

Asked: 2013-10-29 13:54:26 -0600

Seen: 2,532 times

Last updated: Oct 31 '13