C H A P T E R 4 |
Using the Samples |
The samples included with the development kit demonstrate the basic features of the Java Card API, Connected Edition. The samples in this development kit include a simple web application, extended applet application, and classic applet application. Instructions on how to run the samples in this development kit are available in the online help for the Java Card platform plugin in the NetBeans IDE.
In addition to the three samples in this development kit, many additional samples are available through the NetBeans IDE but are located on the kenai.com developer collaboration website. We recommend you access the instructions on how to run the samples located on kenai.com from within the NetBeans IDE as well, although they are also available through your browser on the kenai.com website at http://kenai.com/projects/javacard/pages/Home. The set of samples on kenai.com includes a suite of reference applications that demonstrate an entire application and can be used as a template to illustrate the use of advanced features, such as SIO, event handling, and communication between applications on the card.
Refer to the Runtime Environment Specification, Java Card Platform, Version 3.0.1, Connected Edition and Programming Notes, Java Card 3 Platform, Connected Edition for additional information about designing and writing Java Card 3 applications.
This chapter describes the three samples included in this development kit as they are running in the NetBeans IDE:
All samples must be run from within the NetBeans IDE. They cannot be run from the command line in this release of the development kit. Therefore, this section does not describe how to run the samples, but rather how you interact with them as they are running. For detailed instructions on how to run the samples, see the online help provided with the NetBeans IDE under Help > Help Contents.
Note that two sets of samples are available for the Java Card 3 platform, the three basic samples included in this development kit and the full set of samples that can be found at http://kenai.com/projects/javacard/pages/Home, where how to run them and their use is described.
|
All Java Card 3 platform samples run only from within the NetBeans IDE, Version 6.8 or higher. However, there are two sets of samples available: the three basic samples included in this development kit and the full set of samples on kenai.com, each of which can easily be made into a project from within the NetBeans IDE.
1. If you have not done so, install and set up the NetBeans IDE.
For the details, see Install and Setup the NetBeans IDE.
2. If you want to use the samples in this development kit, run the NetBeans IDE, navigate to the Java Card platform project and then to the appropriate sample node.
The three basic samples are listed in the NetBeans IDE but reside in the development kit in subdirectories of JC_CONNECTED_HOME\samples. The online help provided in the NetBeans IDE under Help > Help Contents contains information on how to run these three samples.
3. If you want to run the samples that reside on kenai.com, from within the NetBeans IDE go to Team > Kenai > Get Sources from Kenai.
In the Get Sources from Kenai dialog box, click the Browse button beside the Kenai Repository field and use search to locate the project Java Card - Everything You Need to Know. Information on how to run these samples is automatically included with each kenai project you create.
4. In the NetBeans IDE, open the sample project.
The NetBeans IDE loads the built application, and, if used, opens the browser to access the application.
5. When they are run, some sample applications open your default browser.
Your browser displays a web page that serves as the primary user interface to some of the samples. Interactions with the three basic samples in the development kit are described in the following sections.
|
When running a sample that uses HTTPS to establish a secure connection with a web server, the Firefox browser might report that the sample uses an untrusted certificate and not allow you to accept the certificate required to open the web page. If cjcre.exe is still running, you can use the browser’s Certificate Manager to add an exception for the server certificate by performing the following procedure.
1. In the Firefox browser menu bar select the Tools > Options menu item.
2. In the Options dialog box, select the Advanced icon in the tool bar.
3. Under the Encryption tab, click View Certificates to open the Certificate Manager.
4. Select the Servers tab and click Add Exception.
5. In the Add Security Exception dialog box, enter the URL of the local host that is displayed in the web browser.
For example, https://localhost:50245
6. Click Get Certificate and accept the certificate loaded by the Certificate Manager.
In some cases, you may need to restart the browser for the certificate to be accepted.
The simplest web application sample, HelloWorld, is included in this development kit. Another version of it is located on the kenai.com website. Both versions are accessible through the NetBeans IDE.
This application demonstrates the basic structure of a Java Card 3 platform application that developers can use to develop, deploy, create, execute, delete, and unload a stand-alone module. It is a minimal application utilizing the simplest source code and meta-files.
This sample contains a web application that demonstrates using a basic web form to collect and display information provided by the user. The project is located in the folder JC_CONNECTED_HOME\samples\web\HelloWorld.
Using this sample consists of starting the HelloWorld application, entering a name in the web page, clicking the Say Hello button on the page, and then receiving the the greeting.
1. Start the HelloWorld application by going to the HelloWorld project node in the NetBeans IDE.
If you need help with running this sample, go to online help within the NetBeans IDE under Help > Help Contents. When running, a browser displays the following page:
2. Enter a name in the Enter Name field and click the Say Hello button.
The browser displays a greeting similar to the following illustration.
This development kit includes the basic classic applet sample, HelloWorld, in the folder JC_CONNECTED_HOME\samples\classic_applets. Another version of it is located on the kenai.com website. Both versions are accessible through the NetBeans IDE.
This sample illustrates basic use of the Java Card API to run a classic applet application and demonstrates the basic structure of a classic applet that developers can use to develop, deploy, create, execute, delete, and unload classic applets. This sample is a minimal classic applet utilizing the simplest source code and meta-files.
This sample contains one project that demonstrates the function of a classic applet. The project is located in the folder JC_CONNECTED_HOME\samples\classic_applets\HelloWorld. Information on how to run this sample is located in the online help for the Java Card 3 platform plugin in the NetBeans IDE under Help > Help Contents.
Using this sample consists of starting the HelloWorld classic applet. When running, the project installs the classic applet, processes an incoming APDU, and responds with a greeting.
This development kit includes the basic extended applet sample, HelloWorld, in JC_CONNECTED_HOME\samples\extended_applets. Another version of it is located on the kenai.com website. Both versions are accessible through the NetBeans IDE.
This sample illustrates basic use of the Java Card API to create an extended applet application and demonstrates the basic structure of an extended applet that developers can use to develop, deploy, create, execute, delete, and unload extended applets. This sample is a minimal extended applet utilizing the simplest source code and meta-files.
This sample contains one project that demonstrates the function of an extended applet. The project is located in the folder JC_CONNECTED_HOME\samples\extended_applets\HelloWorld. Information on how to run this sample is located in the online help for the Java Card 3 platform plugin in the NetBeans IDE under Help > Help Contents.
Using this sample consists of starting the HelloWorld extended applet. When running, the project installs the extended applet, processes an incoming APDU, and responds with a greeting.
Copyright © 2009 Sun Microsystems, Inc. All rights reserved.