从windows访问javax.smartcardio?

时间:2015-01-10 15:18:05

标签: java error-handling smartcard-reader cardreader

import java.util.*;
import javax.smartcardio.*;
public class Terminals{
    public static void main (String [] args) throws Exception{
        TerminalFactory factory = TerminalFactory.getDefault ();
        System.out.println ("Default factory: "+factory);
        dumpTerminals (factory);
        factory = TerminalFactory.getInstance ("PC/SC", null);
        System.out.println ("PC/SC factory: "+factory);
        dumpTerminals (factory);
    }
    static void dumpTerminals (TerminalFactory factory) throws Exception{
        List<CardTerminal> terminals = factory.terminals ().list ();
        for (CardTerminal terminal: terminals)
            System.out.println (terminal);
    }
}    

此代码未检测到WINDOWS 8.1 pro中的COM端口。它打印Default factory: TerminalFactory for type None from provider None和一些错误

Exception in thread "main" java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: PC/SC, provider: SunPCSC, class: sun.security.smartcardio.SunPCSC$Factory)
    at java.security.Provider$Service.newInstance(Provider.java:1259)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:243)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
    at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java:243)
    at Terminals.main(Terminals.java:10)
Caused by: sun.security.smartcardio.PCSCException: SCARD_E_NO_SERVICE
    at sun.security.smartcardio.PCSC.SCardEstablishContext(Native Method)
    at sun.security.smartcardio.PCSCTerminals.initContext(PCSCTerminals.java:56)
    at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:60)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.security.Provider$Service.newInstance(Provider.java:1254)
    ... 4 more

即使MIFARE读卡器连接到COM端口的笔记本电脑。     我尝试多次断开连接永远不会成功。我已经安装了所需的驱动程序,用于读卡器设备驱动程序正常工作。

Why it's not recognising card reader?   

0 个答案:

没有答案