AW-16683449367 Skip to main content

Windows J2A040/JCOP21/31 Java Card Hello World App

Posted by Sonny Yu on Jan 17th 2025

OpenSC and GlobalPlatform Smart Card Setup Guide

Prerequisites

  • Windows PC with administrator access
  • Smart card reader
  • JavaCard-compatible smart card

Installation Steps

1. Install OpenSC

  1. Download OpenSC from the official releases page:
    https://github.com/OpenSC/OpenSC/releases/tag/0.26.0
  2. Run the installer and follow the installation wizard
  3. Default installation path: C:\Program Files\OpenSC Project\OpenSC

2. Install PC/SC Tools

  1. Download pcsc_scan.exe from:
    https://pcsc-tools.apdu.fr/pcsc_scan.exe
  2. Copy pcsc_scan.exe to: C:\Program Files\OpenSC Project\OpenSC\tools

3. Install GlobalPlatform Tool

  1. Download gp.exe from:
    https://javacard.pro/globalplatform/
  2. Copy gp.exe to: C:\Program Files\OpenSC Project\OpenSC\tools

Verification Steps

1. Verify OpenSC Installation

opensc-tool -l

This command should list available smart card readers.

2. Verify GlobalPlatform Installation

gp -info
gp -list

These commands will display information about your smart card and list installed applets.

Working with JavaCard Applets

Installing HelloWorld Sample

  1. Navigate to your home directory
  2. Download helloworld.cap from:
    https://github.com/usasmartcard/Docker_Globalplatform
  3. Run the following commands:
# Remove existing installation if present
gp -uninstall helloworld.cap
# Install the applet
gp -install helloworld.cap

Testing the Installation

Use OpenSC to send APDU commands to the card:

# Select the applet and retrieve data
opensc-tool -s "00 A4 04 00 07 D0 D1 D2 D3 D4 D5 01" -s "00:CB:3F:FF:05:5C:03:5F:C1:02:00"

Troubleshooting

Common issues and solutions:

  • If OpenSC tools aren't found, ensure the installation directory is in your system PATH
  • For GP operations, make sure your smart card is properly inserted and recognized
  • If APDU commands fail, verify the card is properly selected and in the correct state

Additional Resources

Notes

  • Always ensure your smart card is properly inserted before running commands
  • Some operations may require administrative privileges
  • Back up any important card data before performing installations or updates