Ask Your Question
1

OpenCV Java for a multiplatform app

asked 2013-04-08 05:05:14 -0500

Sylvain gravatar image

updated 2013-04-09 08:14:59 -0500

Hi,

I'm trying to create a multiplaform app with OpenCV. The Java Support was pretty much a good news for me :)

I've install OpenCV, create a first app on windows and i'm trying to make an executable jar. But i suppose i'll have a lot of problem thanks to the dll...

I've create in Eclipse a jar who include all the libraries needed. If a create a new project on windows, import my new jar, i can create object declared in my jar but when i run :

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java244 in java.library.path

And if i do the same thing on a RedHat, i've also an error :

Exception in thread "main" java.lang.NoClassDefFoundError: org/opencv/highgui/Highgui
    at core.Ident.ident(Ident.java:84)
    at Main.main(Main.java:13)

(Ident.java:84 is the first line using an OpenCV command)

Would anyone have a tips or a link to a good step-by-step of creating a multiplatform runnable Jar in eclipse with Open CV in it ?

Thanks in advance.

Edit : So... after a day of trying... i havn't succeed with that. But i've found an other way to do it : in eclipse, i've create a dependance between the two project. This way, when i build my project, the dll are found :)

But i still have a problem... how to deal with the dll ? Remember, i want to create a multiplatform app thank's to the java support, and i havn't found any .so files =/

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-04-08 05:42:56 -0500

If you want a standalone jar file that can be imported everywhere and used, you need to include the OpenCV libraries and dll's to your sources inside your jar file. This because the location of your libraries is system specific.

During runtime, it is not finding the correct libraries in your new project. That is what generates the error I guess.

edit flag offensive delete link more

Comments

How can i add this dll ?

When i create my jar in eclipse, i've check the box "Package required library into generated jar"

Sylvain gravatar imageSylvain ( 2013-04-08 06:49:01 -0500 )edit

Hmm I do not know by eclipse, but for me in VS2010 and C++ code, I do not trust the automatic dependency checker. In the menu of creating the *exe (which is same as jar for Java) I manually add all needed resources. Seems to do the trick here. Look on the internet how to add resources to a jar file.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-08 06:56:37 -0500 )edit

So... after a day of trying... i havn't succeed with that. But i've found an other way to do it : in eclipse, i've create a dependance between the two project. This way, when i build my project, the dll are found :)

But i still have a problem... how to deal with the dll ? Remember, i want to create a multiplatform app thank's to the java support, and i havn't found any .so files =/

Sylvain gravatar imageSylvain ( 2013-04-09 08:13:32 -0500 )edit
1

But the minute you create a dependency for an external dll, the jar isn't multiplatform anymore, since a dll isn't simple plafform independent. Won't this form a problem?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-09 08:18:28 -0500 )edit

Yes, that's a problem. That's why i'm don't know how to deal with this dll.

If there was a ".so" file instead of the dll, i will do something like :

String system = System.getProperty("os.name"); if system == Windows extension = "dll"; else extension = "so"

But there is not =/ Or i havn't found how to create them...

Sylvain gravatar imageSylvain ( 2013-04-09 08:37:53 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-08 05:05:14 -0500

Seen: 2,027 times

Last updated: Apr 09 '13