wiki:Java

Using smart cards with Java SE

JNI wrappers

Access to native PKCS#11 providers. Requires JNI and necessary host-side software.

Access to PC/SC for Java versions before 1.6. Should not be used for new applications, use Java 1.6 and javax.smartcardio instead

javax.smartcardio in 1.6+

List of applications and libraries that make use of javax.smartcardio

Tips

  • On Mac OS X 10.6 and 10.7 run the JRE with -d32 to force it into 32bit mode, otherwise smart card events won't work or a crash happens:
    java(2885,0x104c77000) malloc: *** mmap(size=140454020517888) failed (error code=12)
    *** error: can't allocate region
    *** set a breakpoint in malloc_error_break to debug
    Invalid memory access of location 0x0 rip=0x10c0d766e
    Segmentation fault: 11
    
  • Applets and out-of-browser windows:  http://my.opera.com/daniel/blog/2010/05/31/new-opera-with-ns4-javaplugin

PKCS#15 in Java

Similar to the PKCS#15 generation/parsing software in OpenSC, but implemented in Java. Both use  Bouncy Castle for actual ASN.1 encoding/decoding. Both use javax.smartcardio instead of the pcsc/openct/ctapi layer of OpenSC.

GlobalPlatform in Java

GlobalPlatform deals with loading and managing JavaCard applets. There are currently two known implementations of GlobalPlatform specific functionality: