Smartcardio.Terminal connection error in PCSC Gemplus Javacard

前端 未结 1 1397
無奈伤痛
無奈伤痛 2021-01-22 16:22

I am extremely new to Java Card programming. While using javax.Smartcardio in my code, I am getting an error while trying to connect to Gemalto PCSC Java card.

i         


        
相关标签:
1条回答
  • 2021-01-22 17:18

    Check junit test for more example

    jnasmartcardio

    For example I did as follows and manages to detect whether the SMARTCART is connected.

    public class Prueba {
    
    public static void main(String[] args) throws Exception
    {        
        TerminalFactory context;
    
        Security.addProvider(new Smartcardio());
        context = TerminalFactory.getInstance("PC/SC", null, Smartcardio.PROVIDER_NAME);
    
        // Display the list of terminals
        List<CardTerminal> terminals_list = context.terminals().list();
    
        if (terminals_list.isEmpty())
        {
            System.err.println("No existen dispositivos conectados...");
            return;
        }
    
        // Use the first terminal
        CardTerminal terminal = terminals_list.get(0);
    
        if (terminal.isCardPresent())
        {
            System.out.println("La tarjeta electronica esta presente!: "+terminal.getName());
        }
        else
        {
            System.out.println("La tarjeta electronica NO esta presente");
        }
    }
    }
    

    }

    0 讨论(0)
提交回复
热议问题