Managing Applets and Sending APDU Commands

To manage the Java Card applets and send APDU commands use Java Card View and Device Console.

  1. Start the Simulator by right-clicking on Sample_Device in Java Card View and selecting Start.

  2. The console opens with the output from simulator, and a prompt, CMD> You can enter an APDU command, which is sent to the card (Sample_Device), and the response is displayed on the console.

  3. One simple way to test if the console is running is to type the help command at the prompt:

    help;

  4. You should see the available commands.

  5. To load and install a built package, click on the drop down menu from Sample_Device console. The available commands for all imported projects will be displayed. If connect wasn’t done automatically, by default it’s done automatically, click on Connect. In the list are displayed all projects from current workspace with device set for Sample_Device. Under each project submenu, you can find all CAP files assigned to this project and for each CAP file are listed all available commands for specific CAP file. Click first on Load CAP_AID/Package_AID and wait for command execution, then click on Install CAP_AID/Package_AID Applet_AID (package.AppletName).

All available commands:

  • Connect – Performs a card connection to the simulator.
  • Disconnect - Performs a card disconnection from the Simulator. If the Simulator is launched from the Plug-in, you are able to reconnect pressing the connect or writing in console Connect; again.
  • List applets – Displays AID for installed applets on card.

For each CAP file from each Java Card Project submenu, you will have following commands:

  • Load CAP_AID/Package_AID – Loads the applet on the card.
  • Unload CAP_AID/Package_AID – Unloads the Applet_Name from card.
  • Load, Install, Select CAP_AID/Package_AID Applet_AID – Loads, installs and selects the Applet_Name from card in one command.
  • Custom Install CAP_AID/Package_AID Applet_AID (package.AppletName) – Install the loaded applet on the card with Application Specific Parameters and/or with different Applet Instance AID (After this command is executed with different Applet Instance AID, a new Select and Uninstall command will be generated for new Applet Instance AID).
  • Install CAP_AID/Package_AID Applet_AID (package.AppletName) – Install the loaded applet on the card.
  • Select CAP_AID/Package_AID Applet_AID (package.AppletName) – Select the Applet_Name.
  • Uninstall CAP_AID/Package_AID Applet_AID (package.AppletName) – Uninstalls the Applet_Name from card.

Run Configuration

Run Configuration can be used to automate how commands are run. You can specify whether simulator shall be connected or re-connected and provide a list of commands to be executed.

The Run Configuration has option to start simulator, inside eclipse, for you. This option can be disabled and just execute selected commands, the plugin will connect to an already running simulator. The running simulator must match the configuration done in selected device (ex. Sample_Device) for current project (Communication type, Port number and Config file).

Managing HelloWorld sample

These steps show you how to manage the HelloWorld sample. The Java Card Plug-in for Eclipse must already be installed.

Start Eclipse. Sample_Platform and Sample_Device must already be created.

  • Click the File menu, select Import >General > Projects from Folder or Archive, and select the applet directory from the HelloWorld project to import the HelloWorld Java Card project into your workspace. If the build doesn't start automatically, start it manually
  • Start the Sample_Device from Java Card View
    • Right-click on the Sample_Device and press Start
    • If Connect command is not sent automatically, from the drop-down button within the console press Connect

      Note:

      If the Sample_Device console is not selected automatically. From Console View, locate the Sample_Device console under the Display Selected Console drop-down, in the Console View toolbar.
  • Check output of the console for successful connect by checking the response APDU (SW:9000)
  • After a successful connect the drop-down menu will fill with the commands needed for managing the HelloWorld sample
  • From the drop-down menu select HelloWorld > CAP: HelloWorld > Load, Install, Select A00000006203010C01 A00000006203010C0101 (com.oracle.jcclassic.samples.helloworld.HelloWorld)
  • Check that all commands were executed successfully. (SW:9000)
  • Send the following APDU, from the Sample_Device Console: CMD>0x80 0x20 0x00 0x00 0x05 0x31 0x32 0x33 0x34 0x35;
  • The response should look like this: [APDU-R] 80200000053132333435 SW:9000