Java get barcode informaton from barcode scanner

时光总嘲笑我的痴心妄想 提交于 2019-12-12 14:19:52

问题


I have been searching for this. All the related Java APIs are worked on images. They get the information from barcode contained in the images and print barcode to images.

My question is how to get the barcode directly from the scanner in Java? Is there any API I am missing to read barcode directly from scanner? Or, whether I need to generate in-memory image from the information got by the scanner?


回答1:


AFAIK, most of barcode scanners have keyboard emulation mode. You can attach scanner to your PC, scan the barcode and scanner will provide you with barcode information emulating ordinary keypresses which you can capture in any acceptable way (e.g. as keypresslistener or inputfield in Java Swing)




回答2:


Most of modern barcode scanners can be set up to work in serial emulation mode. If you set them up this way, you can communicate with the device as if you are communicating with a normal serial port (read/write). Then you can use a Java library for communicating with the serial device. I used a library called RxTx (http://rxtx.qbang.org/wiki/index.php/Main_Page) which worked great both on Windows and on Linux.



来源:https://stackoverflow.com/questions/13115704/java-get-barcode-informaton-from-barcode-scanner

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!