我正在使用带有java 1.7智能卡读卡器的redhat 8.3
ACS ACR122U和Identive CLOUD 2700 R
java无法检测到智能卡读卡器
我的操作系统版本$>cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)
附有读卡器
$> lsusb
...
Bus 003 Device 003: ID 04e6:5810 SCM Microsystems, Inc. uTrust 2700 R Smart Card Reader
Bus 003 Device 004: ID 072f:2200 Advanced Card Systems, Ltd ACR122U
已安装的 Pcsc 驱动程序版本
$>pcscd --version
pcsc-lite version 1.8.23.
Copyright (C) 1999-2002 by David Corcoran <corcoran@musclecard.com>.
Copyright (C) 2001-2015 by Ludovic Rousseau <ludovic.rousseau@free.fr>.
Copyright (C) 2003-2004 by Damien Sauveron <sauveron@labri.fr>.
Report bugs to <pcsclite-muscle@lists.alioth.debian.org>.
Enabled features: Linux x86_64-redhat-linux-gnu libsystemd serial usb libudev usbdropdir=/usr/lib64/pcsc/drivers ipcdir=/var/run/pcscd configdir=/etc/reader.conf.d
Bus 003 Device 004: ID 072f:2200 Advanced Card Systems, Ltd ACR122U
开始PCSCD服务
$>service pcscd status
Redirecting to /bin/systemctl status pcscd.service
● pcscd.service - PC/SC Smart Card Daemon
Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled)
Active: active (running) since Fri 2021-01-01 15:46:49 +0530; 39min ago
Main PID: 5649 (pcscd)
Tasks: 6 (limit: 48503)
Memory: 1.9M
CGroup: /system.slice/pcscd.service
└─5649 /usr/sbin/pcscd --foreground --auto-exit
Jan 01 15:46:49 localhost.localdomain systemd[1]: Started PC/SC Smart Card Daemon.
爪哇版本
$>java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
示例 Java 程序
import java.util.List;
import javax.smartcardio.*;
public class PCSCTest {
public static void main(String[] args) {
try {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals list size ->"+terminals.size());
//System.out.println(terminals.get(0));
} catch(Exception e) {
e.printStackTrace();
}
}
}
结果是
terminals size-->0
Java 在查找 libpcsclite 共享对象时遇到问题,只需手动提交路径即可
java -Dsun.security.smartcardio.library=/lib/x86_64-linux-gnu/libpcsclite.so.1 -jar Yourjarfile