Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven. Set java.library.path

How I can set 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?

P.S. 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)

like image 684
WelcomeTo Avatar asked Mar 09 '26 19:03

WelcomeTo


2 Answers

How I can set 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.

like image 91
Andrew Thompson Avatar answered Mar 12 '26 09:03

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 for windows or 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.

like image 29
Peter Lawrey Avatar answered Mar 12 '26 09:03

Peter Lawrey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!