Debugging HelloWorld from Eclipse

These steps show you how to debug 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.
  1. Using the File menu, select Import and General to import the HelloWorld Java Card project into your workspace. If the build doesn't start automatically, start it manually.
  2. Make sure debugging information generation is enabled for the HelloWorld package:
    1. In the Package Explorer, expand the HelloWorld and src folder.
      You see the package com.sun.jcclassic.samples.helloworld.
    2. Right-click on com.sun.jcclassic.samples.helloworld and select Java Card and Package Settings.
    3. On the Java Card Package Settings page, select Enable generation of debugging information.
  3. Create a new debug configuration:
    1. Right-click on the HelloWorld project in the Package Explorer and select Debug As and Debug Configurations.
    2. In the Debug Configurations dialog, double-click Java Card Project Debug (in the list). This will a create new debug configuration named HelloWorld.
    3. Select the Java Card tab.
    4. Select the Start simulator in debug mode… and Start debug proxy… options.
    5. We need to add at least one script to be executed on the simulator before the debugger connects. Click Add script.... Browse to the HelloWorld project directory and select the apdu_scripts\cap-com.sun.jcclassic.samples.helloworld.script file. This script will install the applet without creating an applet instance.
    6. Click Debug.
    The debug configuration starts. First, cref is started in debug mode, then the script is executed, the debug proxy is started, and finally the Eclipse debugger connects to the debug proxy.
  4. The Confirm Perspective Switch dialog appears, asking if you want to open the Debug perspective. You may choose to open it, depending on your preference.
    The Debug console shows output from the debug proxy.
  5. In the Package Explorer, locate HelloWorld.java and open it. Set two breakpoints: one in the install() method of the applet, the other in the beginning of the process() method.
    There are several ways to set a breakpoint in Eclipse. In the source code editor, position the cursor on the desired line and do one of the following:
    • Double-click the left most space on the source code line (the line number will be to the right).

    • Press Ctrl + Shift + B to toggle the breakpoint (the type of breakpoint will be selected automatically depending on the source code).

    • Select a specific breakpoint to toggle from the Run menu.

  6. Execute the two remaining scripts in order they appear in the Package Explorer: create-*, then select-* (Right-click on the script and select Java Card and Execute Script).
    After each script runs, execution will suspend on the corresponding breakpoint. Step* and resume debugger commands can  be used  to resume applet code execution.