Pages

Tuesday, January 10, 2012

Boost to starting Java Card

I also faced to lot of difficulties to really start to work with javacard programming. Hope this will be a boost to who starting to learn javacard programming. Here I am not going to give any introduction or theoretical overall about javacard since you can Google and find many resources on the web.

Download jpcsc.jar library from http://www.linuxnet.com/


Context cardContext = new Context();
cardContext.EstablishContext(PCSC.SCOPE_SYSTEM, null, null);
String[] sa = cardContext.ListReaders();
if (sa.length == 0) {
  // there is no reader detected.
} 

try {
    Card card = cardContext.Connect(sa[0], PCSC.SHARE_EXCLUSIVE, PCSC.PROTOCOL_T0);
    System.out.println("Card Get connected");
          // Here After You can transmit APDU commands to card using card.Transmit
    } catch (Exception ex) {
       ex.printStackTrace();
    }

2 comments: