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
- Download OpenSC from the official releases page:
https://github.com/OpenSC/OpenSC/releases/tag/0.26.0 - Run the installer and follow the installation wizard
- Default installation path:
C:\Program Files\OpenSC Project\OpenSC
2. Install PC/SC Tools
- Download pcsc_scan.exe from:
https://pcsc-tools.apdu.fr/pcsc_scan.exe - Copy pcsc_scan.exe to:
C:\Program Files\OpenSC Project\OpenSC\tools
3. Install GlobalPlatform Tool
- Download gp.exe from:
https://javacard.pro/globalplatform/ - 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
- Navigate to your home directory
- Download helloworld.cap from:
https://github.com/usasmartcard/Docker_Globalplatform - 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