A Java Card CAP (Converted Applet) file contains a binary representation of a package of classes that can be installed on a device and used to execute the package’s classes on a Java Card virtual machine. Java Card applets (CAP file) are written in the Java programming language, because applets are designed to run in the very small memory space of a smart card, they’re coded using an appropriate subset of the Java programming language. CAP file contents, such as class information, executable bytecodes, linking information, verification information, and so forth. The CAP file format is optimized for a small footprint by using compact data structures and limited indirection. It defines a bytecode instruction set that is based on and optimized from the Java bytecode instruction set. A CAP file is produced by a Java Card converter when a package of classes is converted. A CAP file consists of a stream of 8-bit bytes. All 16-bit and 32-bit quantities are constructed by reading in two and four consecutive 8-bit bytes, respectively. Multibyte data items are always stored in big-endian order, where the high-order bytes come first. The first bit read of an 8-bit quantity is considered the high bit. 

CAP File Identification

When a CAP file is downloaded and installed into a Java Card the applets are identified in the configuration file by their Application Identifier (AID). Each CAP file has an AID and a version. The AID and version values are dependent on the format of the CAP file (compact and extended) as follows:

  • When the CAP file contains a unique package and it is in the compact format, its AID and version are same as the AID and version of the package it contains.

  • When the CAP file contains multiple packages and it is in the extended format, it has its own AID and version, independent of the AIDs and versions of the packages it contains.

A CAP file can be unzipped. When unzipped the CAP file, you get the following component:

Header.cap: Contains general information about the CAP file.
Directory.cap: Lists the size of each of the components defined in the CAP file.
Applet.cap: Contains an entry for each of applets defined in the package.
Import.cap: Lists the set of packages imported by the classes in the package.
ConstantPool.cap: Contains an entry for each of the classes, methods,and fields referenced by elements in the Method Component.
Class.cap: Describes each of the classes and interfaces defined in the package.
Method.cap: Describes each of the methods declared in this package exclude interface method declaration.
StaticField.cap: Contains all of the information required to create and initialize an image of all of the static fields defined in the package.
RefLocation.cap: Contains all of the linked information that is used in the Method component
Export.cap: Lists all static elements in the package that may be imported by classes in other packages.
Descriptor.cap: Provides sufficient information to parse and verify all elements of the CAP file.
Debug.cap: Contains all necessary meta data for debugging a package.


Related Products

Related Articles

Infineon and Fingerprints step into cooperation on the all-in-one solution SECORA™ Pay Bio that will bring biometric payment cards to a new level

November 24th, 2022|

Munich, Germany and Gothenburg, Sweden – 24 November, 2022 – Infineon Technologies AG (FSE: IFX / OTCQX: IFNNY) and Fingerprint Cards AB (STO: FING B) today announced the signing of a joint development and commercialization agreement of a plug-and-play turnkey

GlobalPlatform SE for IoT workshop: IoT end-to-end security, privacy, simplicity and convenience

March 19th, 2021|

03-19-2021 -- GlobalPlatform, alongside Prime Sponsor, Oracle, and Supporting Sponsors, STMicroelectronics and Able Device, is hosting a free technical workshop on April 13-14 with  extended virtual exhibition hours on April 15. Experts will educate delegates and offer use cases and demonstrations to explain how stakeholders

Categories: Java Card
« Back to Glossary Index