Experto. Establecer java.library.path

como puedo configurar java.library.path in applet using Maven? Usually we can set it by passing parameters to JVM: -Djava.library.path=path/path2. But how I can cause applet to load native libs from java.library.path specified by me?

PS I use 3rd-party Java lib, which uses native .dll. So I think it useless to try preload native lib using System.loadLibrary(relativePath); (because 3rd-party lib in any case retry to load .dll from java.library.path and then throw UnsatisfiedLinkError)

preguntado el 28 de agosto de 12 a las 14:08

2 Respuestas

como puedo configurar java.library.path in applet using Maven?

AFIAU it is not necessary to specify a path so long as the native is on the run-time class-path of the app. Putting it into the root of a Jar referenced as a nativelib in the JNLP should do that.

Respondido 28 ago 12, 14:08

hmm, it's strange, but I put .dll in resources package (of maven project), so this .dll 100% inside classpath, and is located in root of the jar.. But I still get UnsatisfiedLinkError. - Bienvenido a

resolved, forget to change <jar href...> a <nativelib href...> . Thanks. I hope this change not expose my .jar to some additonal restrictions? - Bienvenido a

"hope this change not expose my .jar to some additonal restrictions?" Not as far as I know. Glad you got it sorted. :) - Andrew Thompson

You can set the java.library.path for Maven this way as this is something you set when the program is run, not when it is built.

For an applet the PATH para ventanas o LD_LIBRARY_PATH must be set correctly before the browser starts.

Otherwise you need to use the absolute path and search for the DLL or SO yourself.

BTW: You may have security problems trying to use a shared library from an applet.

Respondido 28 ago 12, 14:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.