Closed mikehearn closed 1 year ago
A couple of notes:
jSerialComm.library.path
with the expected directory containing the pre-extracted native library. (I assume packaging tools would be able to ensure that this property is set when starting up the application?)System.loadLibrary
command before any other loading methods, this has been avoided thus far because it makes it way too easy for a user to inadvertently load a native library version that does not match the corresponding Java-side version of the library doing the loading (for instance, if a user updates the jSerialComm version in their application but doesn't manually update the corresponding native library in their system path). One solution would be to embed the library version in the filename itself so that only the correct/expected version gets loaded. I'm not opposed to making this change, but could you first let me know if Item 1 would be feasible instead?Thanks!
Haha, you'd be surprised what odd places people have ended up putting their native libraries!
Since this can already be achieved with jSerialComm.library.path
, I'm not going to worry about this right now, but I'll add it as an enhancement for an upcoming major release.
This has been implemented in the latest release v2.10.2
Thanks!
When bundling jSerialComm with a JVM, it is often required to pre-extract the shared library so it can be signed, and to avoid littering the user's home directory. For this to work Java code has to try
System.loadLibrary
first before attempting other approaches like extracting from a JAR file. This will search the same location as used by the JVM for its other libraries, and some packaging tools like Conveyor set it to ensure that library copies that might be in c:\windows aren't picked up. Then the packaging process can sign the shared libraries, startup is nice and fast and everything will work fine.