B4J Question [Solved] jssc error with B4JPackager11

bdunkleysmith

Active Member
Licensed User
Longtime User
I have an application utilising jSerial which I've developed over time, but I have encountered an error seemingly related to jssc on transitioning it from Java 8 or OpenJDK 11 .

When run from the IDE, the application runs as expected and the serial port can be selected/opened and data received without error.

However on packaging it using B4JPackager, I receive the following in my log when I launch the application either via run.exe or run_debug.bat:

Java version: 11.0.1
Host Address: 192.168.0.3
BDSScoreboard V16_8 started at 8/1/2020 17:59:49
main._setuplocalforms (java line: -1)
java.lang.UnsatisfiedLinkError: Could not load the jssc library: Couldn't load library library jssc
at b4j/jssc.SerialNativeInterface.<clinit>(Unknown Source)
at b4j/jssc.SerialPortList.<clinit>(Unknown Source)
at b4j/anywheresoftware.b4j.serial.Serial.ListPorts(Unknown Source)
at b4j/b4j.example.main._setuplocalforms(Unknown Source)
at b4j/b4j.example.main._cmbdisplay_valuechanged(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA$1.run(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

So why "Couldn't load library library jssc" when jssc.jar is in my additional libraries folder and in any case the application runs in the IDE?
 

bdunkleysmith

Active Member
Licensed User
Longtime User
I presumed that the jssc.jar contained in the current version (1.31) of the jSerial library would be the correct one, but I replaced it with the jssc.jar from this post even though it pre-dates release of the latest version of jSerial. The jssc.jar in that library archive may be OK for other platforms, but it seems @techknight's is required for OpenJDK11 under Windows 10 64 bit.

As we are reminded in this post, "you MUST go into your windows user profile folder and delete the cache .jssc folder", ie. C:\Users\'username'\.jssc\windows\ folder.
 
Upvote 0

wcieslik

Member
Licensed User
Longtime User
Thanks Man !
That did the trick !
I didn't want to replace it as it was smaller and older than the one I originally swapped in, just to get Serial working ...
but yeah... the 189Kb one works
Thanks again .
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
While the method used above solved the problem at that time, the "correct" way when using the Integrated B4JPackager11 is to follow Tips and special cases #5 in this post Integrated B4JPackager11 - The simple way to distribute standalone UI apps, ie.:

5. If using jSerial put the attached jssc.dll file in the project folder and add:

B4X:
#CustomBuildAction: After Packager, %WINDIR%\System32\robocopy.exe, ..\ temp\build\bin\ jssc.dll
 
Upvote 0
Solution
Top