0

I'm trying to use a JNA library in my project.

My situation is as follows:

I have an applet that shows camera input.

If I run the Applet using the command run as applet I get the correct result:

an applet that shows the camera input

If I remove jna.jar from the build path it gives me error as expected.

If I rename the directory of the native plugins it gives me error as expected.

If I try to run the whole application I get the error:

GStreamer-WARNING **: Failed to load plugin C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstwavparse.dll on 30+ dlls

The path C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\ is the one that if renamed makes the applet crash (so the correct one) and jna.jar and the library that used by JNA are imported in each project involved: the root project from which the application is started and the view project that instantiates the camera showing applet.

As previously suggested, I have tried

System.setProperty("jna.library.path","C:/Users/aaa/Desktop/bbb/ccc/video/library/windows64/plugins/" );

etc... in all possible forms to reference the correct directory but to no avail.

The library is a 3rd party library and actually should work.

The problems may be in my total lack of knowledge of JNA and/or Gstreamer or even of some basics at this point.

Is there any workaround? Why do the applet and application that instantiates the applet work differently when referencing DLLs... or Gstreamer DLLs... or the Processing 2.2.1 included Gstreamer DLLs?

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
J dev
  • 66
  • 1
  • 9
  • I don't understand your question very well personally, but is that the complete error message? – aikeru Jan 06 '17 at 14:53
  • after the warnings when trying to load the plug-ins i get the message java.lang.IllegalArgumentException: No such Gstreamer factory: appsink witch should be a consequence of not being able to load plug ins – J dev Jan 06 '17 at 19:27
  • If you use eclipse, have a look at [this answer](http://stackoverflow.com/questions/15667973/how-to-get-my-program-to-run-outside-of-eclipse/15688065#15688065). The only other addition after the export is to explicitly tell JVM where it should look for java native libraries using ```java.library.path``` (e.g. something like this ```java -jar /path/to/your/processing-applet.jar -cp /path/to/exported-libs -Djava.library.path=/path/to/jni-jna-libs```) – George Profenza Jan 06 '17 at 22:21
  • java.lang.StringIndexOutOfBoundsException: String index out of range: -11 at java.lang.String.substring(Unknown Source) at processing.video.LibraryPath.get(Unknown Source) at processing.video.Video.buildWindowsPaths(Unknown Source) at processing.video.Video.initImpl(Unknown Source) at processing.video.Video.init(Unknown Source) at processing.video.Capture.list(Unknown Source) at processing.video.Capture.list(Unknown Source) – J dev Jan 07 '17 at 11:24
  • I now get this error running the executable jar from cmd with parameters what is changing? – J dev Jan 07 '17 at 11:25
  • i used this: C:\Users\aaa\Desktop>java -jar peerz.jar -cp C:/Users/aaa/Deskto p/bbb/ccc/video/library/windows64/plugins/ – J dev Jan 07 '17 at 11:30
  • C:\Users\aaa\Desktop>java -jar peerz.jar -cp C:/Users/aaa/Desktop/bbb/ccc/video/library/windows64/plugins/ -Djava.library.path=C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstrtpvp8.dll' also same result – J dev Jan 07 '17 at 11:35
  • i mean C:\Users\aaa\Desktop>java -jar peerz.jar -cp C:/Users/aaa/Desktop/bbb/ccc/video/library/windows64/plugins‌​/ -Djava.library.path=C:/Users/aaa/Desktop/bbb/ccc/video/libra‌​ry/\windows64\plugin‌​s – J dev Jan 07 '17 at 11:41

1 Answers1

0

Ok i managed to make it work this way: if i write a main directly in the View project and add the applet to a panel it now works... so that solves some issues(the applet was in a panel even before anyways)... the same exact dummy main gives the warning as before if run under root project alas: failed to load plugin:"correct path"

As said before i have a root project and a view project(N Vproject to be frank) the video lib is included in the VProject and the dlls are under is project resources. Is it possible that running the app from the main project something (like different system variables) end up causing problems? Just not knowing the issue i precedently added and removed(and combinations) all that could be added in relation to jna platform and to tha jna-using-video lib to both projects.

i really do care about uncoupling in this case because im sort of writing a framework and this is a major limitation. Any insight?

J dev
  • 66
  • 1
  • 9