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.
- 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. - Make sure debugging information generation is enabled for the
HelloWorld
package:- In the Package Explorer, expand the
HelloWorld
and src folder.You see the packagecom.sun.jcclassic.samples.helloworld
. - Right-click on
com.sun.jcclassic.samples.helloworld
and select Java Card and Package Settings. - On the Java Card Package Settings page, select Enable generation of debugging information.
- In the Package Explorer, expand the
- Create a new debug configuration:
- Right-click on the
HelloWorld
project in the Package Explorer and select Debug As and Debug Configurations. - In the Debug Configurations dialog, double-click Java Card Project Debug (in the list). This will a create new debug configuration named HelloWorld.
- Select the Java Card tab.
- Select the Start simulator in debug mode… and Start debug proxy… options.
- 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 theapdu_scripts\cap-com.sun.jcclassic.samples.helloworld.script
file. This script will install the applet without creating an applet instance. - 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. - Right-click on the
- 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.
- In the Package Explorer, locate
HelloWorld.java
and open it. Set two breakpoints: one in theinstall()
method of the applet, the other in the beginning of theprocess()
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.
- Execute the two remaining scripts in order they appear in the Package Explorer:
create-*
, thenselect-*
(Right-click on the script and select Java Card and Execute Script).After each script runs, execution will suspend on the corresponding breakpoint.Step*
andresume
debugger commands can be used to resume applet code execution.