0

I build application that using two external libraries the first library is opencv and the second one is swt I finished the application and it's working fine in Eclipse I change to jar file it doesn't work then I change the loaded function jar file from:

System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

to

System.load("/Users/AbdallahRizk/Documents/opencv/opencv-2.4.11/build/lib/libopencv_java2411.dylib");

Note: I'm using mac operating system.

and I export the jar file again and I use the command:

java -XstartOnFirstThread -jar here.jar

because I apply swt library. And the jar file work perfect in my laptop. But once I tried it in the operating system such as ubuntu and windows it doesn't work and I received the following error:

enter image description here

I know that in windows no need for -XstartOnFirstThread but I tried both but I still receiving the same error. I haven't try it yet in another mac operating system but I'm sure it won't work because the loaded opencv library won't be available so I'm trying to packed all the external libraries inside my jar file to work dependently in ubuntu and windows and mac os x.

Based on my research there is a way to do it using maven. Right now I'm using normal eclipse project so any suggestion how to use eclipse to create maven project and export jar file with all the libraries packed inside?

MrRizk
  • 111
  • 5
  • 14
  • check this http://stackoverflow.com/questions/11033603/how-to-create-a-jar-with-external-libraries-included-in-eclipse – Sai Ye Yan Naing Aye Feb 24 '16 at 10:03
  • I made a quick check on "XstartOnFirstThread". You may want to read this: http://stackoverflow.com/questions/28149634/what-does-the-xstartonfirstthread-vm-argument-do-mean Looks a bit like this is an OSX-only option, i.e. not available with Windows oder Linux VMs. – penguineer Feb 24 '16 at 10:05
  • You replacement for System.load will only work on systems where the library has the exact same path. This will most likely not happen in production contexts. – penguineer Feb 24 '16 at 10:06
  • @penguineer I know this that's why I asked if there is any other suggestion that I can add the library in the jar file and change the path to be fixed from the jar it's self – MrRizk Feb 25 '16 at 03:30

1 Answers1

0

the error output is because the application have been developed on eclipse and export on mac platform so it won't work because swt is depend on one platform so to solve the the problem I had to compile everything again and export the jar file using eclipse on windows to be ending with two jars files one for mac and another one for windows.

Second issue the opencv library I build in function to ask about the dll file for windows or dylib file for opencv so the library will be loaded using this command

          System.load(dll_path);

which is dll_path is a string type will be given from the user as a chooser to choose the dll or the dylib file every time it's run

MrRizk
  • 111
  • 5
  • 14