3 Converting and Exporting Java Class Files

This chapter describes how to use the Converter tool, including the input files it can process and the output it produces. How to work with export files is also described.

This chapter contains the following sections:

Overview of Converting and Exporting Java Class Files

The Converter processes all of the Java class files that make up an application (or a library) and creates a binary file (CAP file) that can be deployed and loaded on a Java Card platform. The class files provided as input to the converter must have the class file major version between 45 (Java SE 1.0) and 54 (Java SE 10), and it is recommended to use the JDK 25 compiler to generate them. It also produces other files (export files and JCA files) that are used in the development and deployment process. The CAP file contains a manifest file that provides human-readable information about its content. See Working With CAP Files and Using Export Files, for more information.

Since Java Card Platform Specification, Version 3.1, the CAP file supports the following formats:

The compact CAP file is supported in all Java Card products and offers the binary backward compatibility with all previous formats. The extended CAP file is optionally supported in Java Card products, version 3.1 and above.

Using the Converter in the Compact or Extended Format

The selection of the format (either compact or extended) depends on the following factors:

The format (compact or extended) can be set using the Converter command line parameters. See Running the Converter, for more details about the command line parameters. See Programming Large Java Card Applications with Multiple Packages, for more details about the Extended CAP file.

Using the Converter for a Target Java Card Version

The Converter can be used to create CAP files for Java Card versions 3.0.4, 3.0.5, 3.1.0 and 3.2.0 using the -target [version] command line parameter.

If the CAP file needs to be deployed on multiple Java Card versions, use the oldest version (that is, the smallest version number) as the target.

Table 3-1 Converter Usage

API Version Converter Usage When to Use? CAP File Format Generated

3.0.4

-target 3.0.4

Use this mode when the target platform is 3.0.4.

2.2 (compact)

3.0.5

-target 3.0.5

Use this mode when the target platform is 3.0.5.

2.2 (compact)

3.1.0

-target 3.1.0

Use this format when the target platform is 3.1.0 and the code size is less than 64 K, in one package.

2.3 (compact)

3.2.0

-target 3.2.0 (default)

Use this format when the target platform is 3.2.0 and the code size is less than 64 K in one package.

2.3 (compact)

Using the Converter to Generate a Mask

You might choose to convert packages that import other packages. If you are creating Java Card Assembly files to generate a mask file, then the major and minor version numbers of the imported packages must match the version number of the package that imports them.

See Java Card Assembly Syntax Example, for more information on the Java Card Assembly file.

Setting Java Compiler Options

To set Java compiler options:

  1. When using the recommended compiler (JDK 25) or any Java compiler version 8 or later, configure it to generate Java 8-compatible class files. Use –release 8 when supported; otherwise, use -source 8 -target 8.
  2. Compile your class files with the Java Development Kit compiler’s -g command line option.

The “--release 8” command line option forces the compiler to generate classes with class major version 52, which is recommended class version for the Converter input class files.

The -g option causes the compiler to generate the LocalVariableTable attribute in the class file. The Converter uses this attribute to determine local variable types.

If you do not use the -g option, the Converter attempts to determine the variable types on its own. This is expensive in terms of processing and might not produce the most efficient code. You must also compile your class files with the -g option if you want to generate a debug component in the CAP file by using the Converter’s -debug option.

Do not compile with the -O option. The -O option is not recommended on the Java compiler command line, for the following reasons:

Running the Converter

To run the Converter (use the .sh extension for the shell scripts file in Unix/Linux-like systems and use the .bat extension for batch script files in Windows systems):

  1. For the compact mode, enter either of the following commands at the command line to invoke the Converter:

    converter.[sh | bat] [options] package-name package-AID major-version.minor-version

    Or

    converter.[sh | bat] -config <filename>

  2. For the extended mode, enter the following command at the command line to invoke the Converter:

    converter.[sh | bat] -config <filename.json>

  3. For showing the usage, enter either of the following commands at the command line to invoke the Converter:

    converter.[sh | bat] -help

    Or

    converter.[sh | bat] -help JSON

Note:

The converter.[sh | bat] file used to invoke the actual Converter directly from your working directory is a batch/script file only. If you have added JC_HOME_TOOLS\bin to your PATH you can call it directly, if not, you must precede it with JC_HOME_TOOLS\bin.

The Converter command line options described in the table below allow you to:

When the Converter runs, it performs the conversion process in the following sequence:

  1. Loads the packages - If the exportmap option is set for any of the packages, the Converter loads that package from the export path (see Specifying an Export Map). It loads the class files of the Java packages and creates a data structures to represent these packages.

  2. Subset checking - Checks for unsupported Java features in class files.

  3. Conversion - Checks for consistency between the applet AIDs, package AIDs, CAP file AID (if present), and the imported package AIDs.

  4. Reference Checking - Checks that all references are valid, internal referenced items are defined in the packages belonging to the CAP file, and import items are declared in the export files (see Using Export Files).

    The Converter creates the JcImportTokenTable to store tokens for import items (class, methods, and fields). If the Converter only generates export files, it does not check private APIs and byte code. Also included is a second round of subset checking that operations do not exceed the limitations set by the JCVM specification.

  5. Optimization - Optimizes the byte code.

  6. Generates output - Builds and outputs one EXP export file for each package and one JCA file for each package, checks for each package version in the export file against the version specified in the command line or in the config file. If the -exportmap option is used for a specific package in the command line or config file, the export file specified in the command line for that package must represent the same version as that of the package. The converter does not support upgrading the export file version.

    Before writing the export files and JCA files, the Converter determines the output file path. The Converter assumes the output files are written into the directory:

    [ root_dir/package_dir/javacard | root_dir\package_dir\javacard ]

    By default, the root_dir is the class root directory specified by the -classdir option. You can specify a different root_dir by using the -d option.

    The Converter generates only one CAP file. In the compact mode, the CAP file contains only one package and it is written to the path mentioned into the preceding example [root_dir/package_dir/javacard | root_dir\package_dir\javacard ]. In the extended mode, the CAP file contains one or more packages and it is written into the following directory:

    [ output_dir/CAP_name/javacard | output_dir\CAP_name\javacard ]

    By default, the output_dir is the directory where the JSON configuration file, which used in the extended mode, is located. You can specify a different output_dir by defining a value for the outputDir field in the JSON configuration file.

Table 3-2 Converter Command Line Arguments

Option Description

-help

Prints help message.

-help JSON

Prints a JSON definition file (schema), for the JSON configuration file to be used in extended mode. The JSON schema contains all of the fields that can be defined, the hierarchy of fields, field types, field descriptions, optionality, sample values, default values, and descriptions. The schema can be used (using various tools) for validating configuration files used for generating extended CAP files.

package-name

Fully-qualified name of the package to convert.

package-AID

5 to 16 decimal, hex or octal numbers separated by colons. Each of the numbers must be byte-length.

major-version minor-version

User-defined version of the package.

-applet AID class_name

Sets the default applet AID and the name of the class that defines the applet. If the package contains multiple applet classes, this option must be specified for each class.

-classdir root-directory-of-class hierarchy

Sets the root directory where the Converter looks for classes. If this option is not specified, the Converter uses the current user directory as the root.

-d root-directory-for-output

Sets the root directory for output.

-debug

Generates the optional debug component of a CAP file. If the -mask option is also specified, the file debug.msk is generated in the output directory.

Note: To generate the debug component, you must first compile your class files with the Java compiler's -g option.

-exportmap

Uses the token mapping from the pre-defined export file of the package being converted. The Converter looks for the export file in the exportpath.

-exportpath list-of-directories

Specifies the root directories in which the Converter looks for export files. The separator character for multiple paths is the colon (:) for Unix/Linux OS or the semicolon (;) for Windows OS. If this option is not specified, the Converter sets the export path to the Java classpath.

-i

Instructs the Converter to support the 32-bit integer type.

-mask

Indicates that the converted code is intended to be used to create a binary mask, so restrictions on native methods are relaxed. If you have a source release, you can specify this option to generate a mask out of this package using maskgen.

This option can be used in conjunction with -out CAP, only if -debug is selected, to typically generate a CAP with debug component and use it to debug platform classes. Such CAP is not intended to be loaded on a platform and will fail verification if it contains native methods.

-nobanner

Suppresses all banner messages.

-noverify

Suppresses the verification of input and output files. For more information on file verification, see Verification of Input and Output Files.

-nowarn

Instructs the Converter not to report warning messages.

-out [CAP] [EXP] [JCA]

Instructs the Converter to output the CAP file, and/or the export file, and/or the Java Card Assembly file. By default (if this option is not specified), the Converter outputs a CAP file and an export file.

-v, -verbose

Enables verbose output. Verbose output includes progress messages, such as "opening file", "closing file", and whether the package requires integer data type support.

-V, -version

Prints the Converter version string.

-sign

Specifies to sign the output CAP file.

-keystore value

Keystore to use in signing.

-storepass value

Keystore password.

-alias value

Keystore alias to use in signing.

-passkey value

Alias password.

-useproxyclass

Cannot be specified with keepproxysource. Builds CAP files as usual in the specified output directory using the existing class files of the application and existing class files of the associated proxy sub-package. New proxy classes are not created.

Provides a way for the application developer to build a CAP file with customized proxy files. This option requests the converter to take the class files of the application package and the class files of the co-located proxy sub-package to build a new CAP file. The classes in the application package are converted into new.cap components. New descriptors are created. Dynamically-loaded-classes attributes need to be recomputed based on the new Proxy class file names.

-usecapcomponents

Specifies that the converter retain the specified user supplied CAP components instead of generating them in the final CAP bundle. The input format is as follows:

application-classes-dir/application-classes/javacard/*.cap

-keepproxysource directory

Cannot be used with -useproxyclass. Creates the proxy source files and other stub files in the specified directory. The converter also builds CAP files as usual in the specified output directory.

Supports customizing the proxy files generated by the converter. Requests the converter retain the intermediate proxy class source code in the specified directory and the source code of the associated stub classes representing the dependent external classes using the hierarchical directory structure of the Java package name(s).

-resourcepath <id1>:<resource_path1>,<id2>:<resource_path2>,...

Specifies the list of static resources that can be loaded into the CAP file that is generated by the Converter (in the compact mode).

The entries in the list are delimited by the "," character. Each entry in the list contains two parameters delimited by the ":" character. The first parameter is an integer representing the id of the static resource and the second parameter is the path to the file, which has the actual binary content for the static resource. The path must be a valid path to a file on the disk for which the Converter should have read access.

-target <platform version>

Specifies the Java Card platform version on which the CAP file that is generated by the Converter (in the compact mode) is loaded.

If -target is not specified, the default value would be the latest release version, that is, 3.2.0. Other valid values for -target are 3.0.4, 3.0.5, and 3.1.0. If you omit the -target option or if you are using a target greater than 3.0.5, the 2.3 version CAP files are generated. Otherwise, 2.2 or 2.1 version CAP files are generated, depending on the used features (debugging or RMI). Additionally, for the current release, the platform's api_export_files directory is not required to be given in the -exportpath option, it is chosen automatically based on the -target option.

-enable-preview [final|all] Enables support for Java Card preview features when generating a CAP file in compact mode, indicating that the target Java Card platform where the CAP will be loaded implements preview features. The following variants are supported:
  • -enable-preview final enables only the features that have reached their final state and will be included permanently in the next specification version.
  • -enable-preview [all] (default) enables both evolving and finalized preview features.
When -enable-preview is specified, the converter only supports targeting the latest Java Card platform version. Any other value provided for the -target option in combination with -enable-preview is rejected.

Using Delimiters with Command Line Options

To use delimiters with command line options:

  1. Add a double quote (“) around command line option arguments that contain a space symbol.

In the following sample command line, the Converter checks for export files in both the .\export files and current directory.

converter.[sh|bat] -target 3.0.5 -exportpath ["./export files":. |
".\export files";.] MyWallet 0xa0:0x00:0x00:0x00:0x62:0x12:0x34 1.0

Using a Command Configuration File in Compact Mode

Instead of entering all of the command line arguments and options on the command line, you can include them in a text-format configuration file. This is convenient if you frequently use the same set of arguments and options.

To use a command configuration file:

  1. Enter the command line arguments and options in a text-format configuration file.

  2. Use double quote (“) delimiters for the command line options that require arguments in the configuration file.

    You must use double quote (“) delimiters for the command line options that require arguments in the configuration file. For example, if the options from the command line example used in Using Delimiters with Command Line Options were placed in a configuration file, the result would look like this:

    converter.[sh|bat] -target 3.0.5 -exportpath ["./export files":. | ".\export files";.] MyWallet 0xa0:0x00:0x00:0x00:0x62:0x12:0x34 1.0

  3. Specify the configuration file in the command line when you run the Converter.

    The syntax to specify a configuration file is:

    converter.[sh | bat] -config configuration file name

    The configuration file name argument contains the file path and file name of the configuration file.

    If the name of the configuration file has the .json extension, the extended mode is activated, else the compact mode is used.

Using a JSON Configuration File for Converter in the Extended Mode

In the extended mode, the Converter tool generates extended CAP files from one or multiple Java packages.

To run the Converter in the extended mode, use a JSON configuration file with the -config option. The JSON file includes fields and options that are used in the compact mode, however most of these fields and options are associated with each package contained in the CAP file.

The configuration in the JSON file is a JSON object with a single field, inputConfig. All other fields are defined inside this field at different levels of hierarchy. The description of levels follow:

Table 3-3 JSON File Options for Converter

Option Level Description
CAP_AID CAP file The AID of the CAP file available as an executable load module.
CAP_name CAP file The name of the CAP file generated by the Converter. On the disk, the name of the CAP file would look like <CAP_name>.cap and all the components inside the CAP file will be located in the <CAP_name>/javacard directory.
CAP_version CAP file The user-defined version of the CAP file as an executable load module.
debug CAP file Generates the optional debug component of a CAP file. The same rules apply to the compact mode.
noverify CAP file Suppresses the verification of input and output files. The same rules apply to the compact mode.
verbose CAP file Enables verbose output.
outputDir CAP file Sets the root directory for output of the CAP file.
nowarn CAP file Instructs the Converter not to report warning messages.
nobanner CAP file Suppresses all banner messages.
useCapComponents CAP file Instructs the Converter to retain the user-defined CAP components instead of generating them in the final CAP bundle. The input format is as follows:

<CAP_name>/javacard/*.cap

CAP CAP file Instructs the Converter to write or not to write the CAP file to the disk.
integer CAP file Instructs the Converter to support the 32-bit integer type.
exportPath CAP file Specifies the root directories in which the Converter looks for the export files. The same rules apply for the compact mode. Note that the Java Card API framework export files directory is not required.
target CAP file Specifies the Java Card platform version on which the CAP file that is generated by the Converter (in the extended mode) is loaded. If the target is not specified, the default value would be the latest release version, that is 3.2.0. The other valid value for the current release is 3.1.0. Extended CAP files are 2.3 version CAP files no matter the target platform used.
inputPackages CAP file An array of JSON objects, each representing the configuration for the Java package to be converted and added to the CAP file.
staticResources CAP file An array of JSON objects, each representing the configuration for a static resource to be loaded on the CAP file.
sign CAP file A JSON object representing the configuration for signing the CAP file, which is generated by the Converter.
PackageAID Package The AID of the package as defined in the compact mode.
PackageName Package The fully-qualified name of the package as defined in the compact mode.
baseDir Package Sets the root directory from where the Converter looks for the classes in the package. If this option is not specified, the Converter uses the location of the configuration file as the root directory.
outputDir Package Sets the root directory for output of the JCA and EXP files generated for this package. The same rules apply for the compact mode. If this option is not set, the baseDir value is taken.
public Package Specifies if a package is exported or not. The values and its description follow:
  • If the value is set to true, and the package is a library, then all the public classes and interfaces are exported.
  • If the value is set to true, and the package is an applet package, then only shareable interfaces are exported.
  • If the value is set to false, nothing from the package is exported. Also, the AID field of the package will not appear in the header component of the CAP file and the AID field is ignored. Because of this, in the generated JCA files, the AID of a private package will have a random value. For a private package, the EXP file is not generated and the value of the EXP file is ignored.
version Package The user-defined version of the package as defined in the compact mode. If the package is private and the exportmap field is set to false, the version field is ignored.
JCA Package Instructs the Converter to write or not to write the JCA file to the disk for the package.
EXP Package Instructs the Converter to write or not to write the EXP file to the disk for the package.

If the package doesn't have an export component (if the package is private or an applet package with no shareable interfaces), the EXP file is not generated. Therefore, the EXP field is ignored.

exportmap Package Uses the token mapping from the predefined export file of the package. The Converter looks for the export file in the given exportpath at the CAP file level. If this field is set to false and the package is private, the version field is ignored.
applets Package An array of JSON objects. Each representing the configuration for a Java Card applet contained in this package.
ClassAID Applet Specifies the AID of the applet.
ClassName Applet Specifies the fully-qualified Java class name for this applet.
id Static Resource An integer representing the identification number for the static resource. The static resource IDs must be unique across the CAP file.
file Static Resource A valid system path to an existing and accessible file on the disk. The contents of this file is loaded as binary data in the CAP file for the static resource.
keystore Sign The keystore used in signing.
storepass Sign The keystore password.
alias Sign The keystore alias used in signing.
passkey Sign The alias password.
Handling Relative Paths

In the JSON configuration file, all the fields that have values for the paths to directories or files on disk, support relative paths.

These fields include: outputDir, baseDir, exportPath, and file. All the relative paths are defined relative to the directory in which the JSON configuration file is located.

For example, the static resources are defined as follows (in Unix/Linux OS replace \ with /):

"staticResources":[{
                       "id": 1,
                       "file" : "staticres\\static1.res"
                    }, {
                       "id": 2,
                       "file" : "staticres\\static2.res"
                    }]

If the JSON configuration file is in the following location (in Unix/Linux OS replace \ with / and a proper Unix/Linux OS path):

C:\Users\Test

Then the Converter finds the data for the static resources in the following locations (in Unix/Linux OS replace \ with / and a proper Unix/Linux OS path):

C:\Users\Test\staticres\static1.res
C:\Users\Test\staticres\static2.res

This applies for any input or output relative path directory. In case of a list of paths, like the exportPath field, the preceding statements apply for each path in the list.

Converter JSON Configuration File Sample

The following is an example of the converter JSON configuration.

Note that if you are using Unix/Linux OS, replace all \\ references with / and all semicolons (;) with colons (:):

{
    "inputConfig": {
        "CAP_AID": "01:02:03:04:05:10",
        "CAP_name": "hellosample",
        "CAP_version":"1.0",
        "debug": true,
        "noverify":false,
        "verbose": true,
        "outputDir": "thecapfile",
        "exportPath": ".;.\\package1",
        "inputPackages":[{
            "baseDir":"package1",
            "PackageName": "com.lib",
            "PackageAID": "01:02:03:04:05:06",
            "public": true,
            "JCA": true,
            "EXP": true,
            "exportmap": true,
            "version": "1.1"
        },{
            "PackageName": "com.mine",
            "baseDir":"package2",
            "public": false,
            "JCA": true,
            "EXP": false,
            "exportmap": false
         },{
            "PackageName": "com.sample",
            "PackageAID": "01:02:03:04:05:07",
            "baseDir": "package3",
            "public": true,
            "version": "1.0",
            "JCA": true,
            "EXP": true,
            "exportmap": false,
            "applets": [{
                "ClassAID": "01:02:03:04:05:07:01",
                "ClassName": "com.sample.MyApplet"
            }]
        }],
        "staticResources":[{
            "id" : 1,
            "file" : "staticres\\static1.res"
        },{
            "id": 2,
            "file" : "staticres\\static2.res"
        }]
    }
}
Validating a JSON Configuration File

To validate a JSON configuration file, a JSON schema file must be generated using the -help JSON option.

To save the schema file, use the following command:

converter.[sh|bat] -help JSON > converter_schema.json

The saved schema file can be used as an input to the validation tools for validating the actual JSON configuration files that are passed to the Converter. See https://json-schema.org, for more information on JSON schema and validation.

File Naming for the Converter

This section describes the names of input and output files for the Converter, and gives the correct location for these files. With some exceptions, the Converter follows the Java programming language naming conventions for default directories for input and output files. These naming conventions comply with the definitions in the Java Card Virtual Machine specification.

This section includes the following:

Input File Naming Conventions

The input files for the Converter are Java class files named with the .class suffix. Generally, there are several class files making up a package. All the class files for a package must be located in the same directory under the root directory, following the Java programming language naming conventions. In the compact mode, the root directory can be set from the command line using the -classdir option. If this option is not specified, the root directory defaults to the directory from which the user invoked the Converter. In the extended mode, the root directory can be set from the JSON configuration file using the baseDir field. This is set for each package contained in the extended CAP file. If the field is not specified for a specific package, the root directory for that package defaults to the directory in which the JSON configuration file resides.

Suppose, for example, you want to convert the package java.lang. If you use the -classdir flag to specify the root directory as /home/mywork (Unix/Linux OS) or C:\mywork (Windows OS), the command line is:

converter.[sh|bat] -classdir [/home/mywork|C:\mywork] java.lang package_AID package_version

where package_AID is the application ID of the package and package_version is the user-defined version of the package.

If you use the baseDir field to specify the root directory as /home/mywork or C:\mywork, the JSON field looks like this: "baseDir":"/home/mywork for Unix/Linux OS or "baseDir":"C:\\mywork" for Windows OS

The Converter looks for all class files in the java.lang package in the directory /home/mywork/java/lang on Unix/Linux OS or C:\mywork\java\lang on Windows OS.

Output File Naming Conventions

In the compact mode, the name of the CAP file, export file, and the Java Card Assembly file must be the last portion of the package name followed by the extensions .cap, .exp, and .jca, respectively. In the extended mode, the name of the CAP file is the value of the CAP_name field defined in the JSON configuration file followed by the .cap extension. For the export files and Java Card Assembly files generated in this mode, the same rules as in the compact mode apply.

By default, the files output from the Converter are written to a directory called javacard. This is a subdirectory of the input package’s directory for the compact mode, or a subdirectory of the CAP name directory for the extended mode.

In the above -classdir example, by default, the output files are written to the directory

[ /home/mywork/java/lang/javacard | C:\mywork\java\lang\javacard ]

In the above baseDir example, assume that if the CAP_name field has the “hellosample” value, by default, the output files are written to the directory [ /home/mywork/hellosample/javacard | C:\mywork\hellosample\javacard ].

The -d flag or the outputDir field enable you to specify a different root directory for the output.

In the above example, if you use the -d flag or the outputDir field to specify the root directory for the output to be [/home/myoutput | C:\myoutput ], the Converter writes the output files to the directory [/home/myoutput/java/lang/javacard | C:\myoutput\java\lang\javacard ] or [/home/myoutput/hellosample/javacard | C:\myoutput\hellosample\javacard ], respectively.

When generating a CAP file, the Converter creates one or more Java Card Assembly files in the output directory as an intermediate result. If you don’t want a Java Card Assembly file to be produced, omit the option -out JCA in the compact mode or set the JCA field to false for the respective package in the JSON configuration file in the extended mode. The Converter deletes the Java Card Assembly files at the end of the conversion.

Verification of Input and Output Files

By default, the Converter invokes the Java Card technology-based off-card verifier (“Java Card off-card verifier”) for every input EXP file and on the output CAP and EXP files.

If you want to bypass verification of your input and output files, use the -noverify command line option or set the noverify field in the JSON configuration file to true. Note that if the Converter finds any errors, output files are not produced.

Note:

When using the Java Card off-card verifier to verify an extended CAP file, all EXP files that are required by the packages and are present inside the extended CAP file, must pass the verification.

Creating a debug.msk Output File

To create a debug.msk output file:

  1. Set the -mask and -debug options described in Converter Command Line Arguments when you run the Converter.
  2. Verify that the file debug.msk is created in the same directory as the other output files.

Using Export Files

A Java Card technology-based export file contains the public API linking information of classes in an entire package. The Unicode string names of classes, methods and fields are assigned unique numeric tokens.

Export files are not used directly on a device that implements a Java Card virtual machine. However, the information in an export file is critical to the operation of the virtual machine on a device. An export file is produced by the Converter when a package is converted. You can use this package’s export file later to convert another package that imports classes from the first package. Information in the export file is included in the CAP file of the second package, then is used on the device to link the contents of the second package to items imported from the first package.

During the conversion, when the code in the currently converted package references a different package, the Converter loads the export file of the different package. The Converter also tries to load the shareable interface class files being imported from that package.

For more information on export files, see Verifying CAP and Export Files .

Calls Between Packages Go Through the Export Files illustrates how an applet package is linked with the java.lang, the javacard.framework and javacard.security packages through their export files.

You can use the -exportpath command option and the exportPath JSON field to specify the locations of export files and the shareable interface class files. The path consists of a list of root directories in which the Converter looks for export files and shareable interface class files. Export files must be named as the last portion of the package name followed by the extension .exp. Export files are located in a subdirectory called javacard, following the relative directory path that matches the package name. The shareable interface class files are located in the relative directory path that matches the package name.

For example, to load the export file of the package java.lang, if you have specified -exportpath as c:\myexportfiles, the Converter searches the directory c:\myexportfiles\java\lang\javacard for the export file lang.exp.

Figure 3-1 Calls Between Packages Go Through the Export Files

Description of the illustration calls-thu-export-files.png

Specifying an Export Map

By specifying an export map, you can request the Converter to convert a package by using the tokens in the pre-defined export file of the package that is being converted. There are two distinct cases when using the -exportmap flag:

For example, if you have developed a package and would like to reimplement a method (package reimplementation) or upgrade the package by adding new API elements (new exportable classes or new public or protected methods or fields to already existing exportable classes), you must use the -exportmap option to preserve binary compatibility with already existing packages that use your package.

To specify an export map:

  1. Set the -exportmap command option described in Converter Command Line Arguments when you run the Converter in the compact mode.

    The Converter loads the pre-defined export file in the same way that it loads other export files.

  2. Set the exportmap JSON field to true for each package from an extended CAP file, for which you want to preserve binary compatibility, in the extended mode.

Viewing an Export File as Text

The exp2text tool is provided to allow you to view any export file in text format. The file to invoke exp2text is a script file (exp2text.[sh|bat]). It is located under [$JC_HOME_TOOLS/bin | %JC_HOME_TOOLS%\bin] and needs to be executed from there.

To view an export file as text:

  1. Enter the following command (see exp2text Command Line Options for a description of the options):

exp2text.[sh|bat] [options] package-name

Table 3-4 exp2text Command Line Options

Option Description

-help

Prints help message.

-classdir input-root-directory

Specifies the root directory where the program looks for the export file.

-d output-root-directory

Specifies the root directory for output.