I'm trying to create a sim开发者_StackOverflow社区ple Java applet that reads data coming in through a serial port. Is it possible?
By default, Java has no support for communicating with serial ports. There are libraries like RXTX that allow you to do that, but unfortunately RXTX requires a platform-specific native library in order to use the serial ports.
Further complication is that Java applets run in a very restricted sandbox by default, which means you need to a) sign the applet and b) manually install the necessary RXTX libraries on the host computer, which is not that user-friendly.
An alternative solution is discussed in this SO question (in short: use Java Web Start, not an applet, and everything gets a lot easier).
Yes, it is possible. Having said that, I think @andri pointed out the best path to a solution.
For that you can use jSSC lib (Java Simple Serial Connector). Page on google code: http://code.google.com/p/java-simple-serial-connector/
Also see this page: http://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal
This is jSSC based serial port terminal applet. Source code of jSSC-Terminal you can download on "Downloads" page.
Best regards, Sokolov Alexey.
精彩评论