Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
523 views
in Technique[技术] by (71.8m points)

java - add javax.comm API on a mac

I would like make an java app that communicates with a serial device(handheld scanner) so that the app is platform independent. I have found a few code examples, and when I copy them into Eclipse it says that javax.comm.* is missing. How do I install this on my Mac? And how do I add this library to my app so that the users does not have to install anything?

I want to able to give the users a jar file and the device, and they should be able to run it on windows/Mac/Linux without little or none configuration.

I found a download where I could download a javax.comm.jar file but the download included a win32comm.dll it dependented on some how - at least that was the fault I got when I added the jar file to my project.

Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is the Java Communications API. You can get it here but it won't help you. The supported platforms are Solaris SPARC, Solaris x86, and Linux x86.

For Mac and Linux, if the serial port is already configured, you can open /dev/ttyS0, /dev/ttyS1, /dev/ttyS2, etc. as a file and read/write to it. On Windows, if the serial port is already configured you can open "COM1", "COM2", etc. and read and write to it.

Unfortunately, javax.comm (as provided in the reference implementation) isn't cross-platform, so you'll have to either resort to bundling additional native libraries and supporting classes or use a platform-dependent way to configure the serial port. On Windows, this could be the "mode" command, and on Mac/Linux, this could be the stty command.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...