How can I use Java to communicate to device throug

2020-07-06 08:17发布

I just recently learn Java and try to communicate to the device through USB port connection. I've have used C# with OpenNETCF which allows me to send file and retrieve file on the device through USB port; how can I achieve this with java?

I seearch on stackoverflow thread, How to communicate with a USB device under Windows and Java?, the comment made by christoffer is to hack the native code, but I don't quite which native code api that he referred to. RAPI, maybe?

5条回答
女痞
2楼-- · 2020-07-06 08:22

The only USB API I could find for Windows is here. Seems as if it has limited functionality, but it might suit your needs. A more complete UNIX API is also available.

ETA: Found a link to the official Java USB implementation, but looks like the windows version is still in alpha.

查看更多
虎瘦雄心在
3楼-- · 2020-07-06 08:28

The native code API I referred to was the Windows DDK, i.e. the Driver Development Kit. The modern version seem to be called Windows Driver Kit, so google for Windows WDK :) There should be a few C samples on how to communicate with USB devices, and it should be pretty straightforward to write a JNI wrapper from those.

查看更多
手持菜刀,她持情操
4楼-- · 2020-07-06 08:42

I found this page that explains how to perform a communication between a microcontroller and a java application: http://javausbapi.blogspot.com/

查看更多
Viruses.
5楼-- · 2020-07-06 08:44

As a quick thought, you could use JNI, the Java Native Interface. I've never used it myself though.

查看更多
smile是对你的礼貌
6楼-- · 2020-07-06 08:46

The Best way I found to communicate with USB is through RxTx library.

You can find an example of the usage here: http://www.snip2code.com/Snippet/1044/Java--read-from-USB-using-RXTX-library

查看更多
登录 后发表回答