I am doing some serial communication via Java Applet and rxtx library. Applet is working fine but when loaded more then once I am having issues with
UnsatisfiedLinkError: rxtxSerial.dll already loaded in another classloader
Following How to unload library (DLL) from java JVM I am trying to unload dll, which I believe could help with this issue.
From what I understood I could have custom class loader for rxtx class and force garbage collector to clean everything, including loaded dll, at some point.
So the following code should help (I am trying to load it in the function responsible for starting communication with serial port).
cl = new CustomClassLoader();
ca = cl.findClass("gnu.io.CommPortIdentifier");
a = ca.newInstance();
p = ca.getMethod("getPortIdentifier");
portId = (CommPortIdentifier) p.invoke(a, comportUsed);
unfortunately it throws ClassNotFoundException
I guess something is wrong with my custom class loader, but have no clue what.
Please help me finding that or a way to overcome UnsatisfiedLinkError
.