Dynamically loading a native library inside Java applet

Dario picture Dario · Mar 13, 2009 · Viewed 11k times · Source

I am trying to write a Java applet that will read from a user's serial port. For this I am using the Java Comm API in conjuction with the RXTX library. I've successfully managed to read data through a local Java application but I can't seem to do the same from within an applet. The problem is that the RXTX library is a native library and I haven't found a way to load this library inside the Java applet. I've found two interesting articles (Using JNI in Applets which references to this article), but both are over 10 years old and I am wondering if there is a newer solution. Or if you can suggest an alternative, I would love to hear it!

Answer

Ted Leung picture Ted Leung · May 5, 2009

Use Java Web Start. You can include the native library as a signed jar and everything should work.

1) put the native librarys in a jar in the ROOT directory 2) sign ALL the jars 3) write a JNLP referencing all the jars (go do a search on how to write jnlp's)

after that it should work