Running the Samples in Visual Studio Code
Before running the samples in VS Code, make sure you have the proper setup by following the steps in the How to Run the Samples section of the Developer Kit Simulator User Guide. An introductory explanation of the samples is available, along with information concerning configuration of the Java Card Development Kit Simulator and other helpful links.
To run a sample, open the workspace projects, build them, start the device, and then run the sample-specific client Java application which loads the applet(s), sends necessary APDUs and cleans up afterwards.
Open the Workspace Project
Each sample comes with a defined Workspace configuration file. To open a
Workspace directory, go to File>Open Workspace from File…, and then
select the Sample workspace file (e.g. HelloWorld.code-workspace
)
you want to use from JC_HOME_SIMULATOR/samples
.
In the file explorer, the Workspace contains two project directories, one
for the applet and one for the client. Inside each
project, there is a Maven pom.xml
file to enable a development
environment for each project using Java Platform Extension. Additionally,
each project has a set of specific Launch Configurations and Tasks
inside its .vscode
directories.
Before running the configurations, change the profile you are using by going to File > Preferences > Profiles, then choose Java Card Profile from one of your profiles.
Convert and Verify the Applet
For the conversion of the applet, the sample contains a launch configuration called Convert and Verify Applet. The launch configuration does not require any additional configuration to run. To run the configuration, go to Run and Debug, and select the configuration from the dropdown menu.
Then launch the configuration from Run > Start Debugging
(F5). The Configuration will build and launch the conversion tools script
(converter.sh
/converter.bat
). At the end, a
terminal instance will show the results of the conversion. The message “conversion
completed with 0 errors” means a successful conversion.
Running the Simulator Device
The applet project also contains a launch configuration for running the Simulator. Start the simulator by selecting “Start Java Card Simulator” configuration, and then launch the configuration from Run > Start Debugging (F5). A terminal will open with the output of the simulator process inside.
Running the Client
Each workspace also contains the client project. To run the client, select “Run Java Card Client” then launch the configuration from Run > Start Debugging (F5). This configuration will use Java Platform Extension to build and run the client from the maven file.
The output of the client can be seen inside the Debug Console for the “Run Java Card Client” configuration.
Look for the dropdown menu in the top-right corner of the Debug Console section. This dropdown allows you to switch between different debugging sessions. Click on it, and you'll see an option for "Run Java Card Client"—select it. Once you do, the Debug Console will now show logs and debug information specifically for the client.