JavaCard Basics
A JavaCard is a smart card that is capable of running Java programs[1]. The JavaCard 2.1 specification is available at SUN's home page[2]. At this site, you can find the detailed information about JCVM(JavaCard Virtual Machine) and API(Application Programming Interface).
The JCVM is implemented as two separated pieces. The first is that runs off-card and the other that runs on-card. Tasks that are not constrained to execute at runtime, such as class loading, bytecode verification, resolution and linking, and optimization, are dedicated to the virtual machine that is running off-card(i.e., smart card terminal such as PC or workstation) where resources are usually not a concern. The second, on-card part of JCVM, includes byte code interpreter. It is mostly executed at JCRE(JavaCard Runtime Environment).
Because of smart card's characteristics(small memory, low processing power, etc), the JavaCard platform supports only a subset of the features of the Java language. For example, several data types(including long, double, float, string, multidimensional arrays) are not supported. Dynamic class loading, threading and garbage collection are not supported[2].
The communication mechanism between JavaCards and the card terminals is described at ISO 7816 specification[3]. The messages are referred to as the APDU(Application Protocol Data Unit). The JavaCard application, an applet, has a life cycle consisting of the special state cycle. More information on this are described at [1].
JavaCard applets can be implemented using conventional Java development tools such as VisualCafe or JDK. Generally, it offers a JavaCard simulator which lets applet developers do not need a physical card and card reader. A converter, CAP(Card Applet) file generator and APDU tool are also offered. After compiling Java source code, the converter loads and preprocesses the class files that make up a Java package and outputs a CAP file. The CAP file is then loaded on a JavaCard and executed by the interpreter at the JCRE. In addition to creating a CAP file, the converter generates an export file representing the public APIs of the package being converted.
[1] Zhiqun Chen, JavaCard Technology for Smart Cards-Architecture and programmer¡¯s Guide, Addison-Wesley, 2000.
[2] Sun Microsystems Inc., JavaCard 2.1 Virtual Machine Specification, available http://java.sun.com/products/javacard
[3] ISO/IEC 7816-5: Integrated circuit(s) cards with contacts-Part 5: Numbering system and registration procedure for application identifiers