Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.34k stars 287 forks source link

Support for pre-extracted native libraries #426

Closed arthurgent closed 2 years ago

arthurgent commented 2 years ago

As it is, jSerialComm can't be used on some hardened systems where all "temp"-directories and "user home"-directories have "noexec" flag set (i.e. users are not allowed to create and run their own binaries or libraries in any way).

So I would suggest a new feature where the library path to native libraries can be set manually to a directory that containt pre-extracted platform specific native library (or all libraries). Override could be done by -DjSerialComm.library.path= where is either an absolute (e.g. "/usr/lib") or a relative path (e.g. "lib/native") to a directory that contains the native library.

As an example JFFI project contains .dll and .so files in a .jar just like jSerialComm, but the library path can be manually overridden by using -Djffi.boot.library.path=. JFFI first tries to find libraries in arch specific subfolders like _/x8664-Windows but then reverts to root if subfolders do not exist.

See JFFI StubLoader

https://github.com/jnr/jffi/blob/master/src/main/java/com/kenai/jffi/internal/StubLoader.java

hedgecrw commented 2 years ago

This seems like a reasonable and useful request. I will include it as a new feature for the next version. Thanks!

hedgecrw commented 2 years ago

Please test the following updated version and see if it works for your needs. Support for the pre-extracted native libraries works exactly as you described in your initial message:

https://www.dropbox.com/t/qQJEhdFDRfEsnI8z

If this works, I will check in the fix and include it in the next release coming out shortly.

hedgecrw commented 2 years ago

This was included in today's jSerialComm v2.9.2 release. I will be updating the Wiki documentation shortly to include instructions on how to use it. Thanks!