S.
Bouzefrane
How to set up the Java Card development
environment under Windows?
Samia Bouzefrane
[Link]@[Link]
1 Java Card Classic Edition- August 2012
S. Bouzefrane
I. Development tools
I.1. Hardware
1. A Java Card platform (Java smart card).
2. A card reader.
I.2. Software
a) Download and install JDK 1.7 (use this link to download:
[Link]
[Link] ).
b) Download Eclipse IDE for Java Developers
([Link] ).
c) Download the file [Link] from:
([Link] ) and
store it in a local folder. This file is an eclipse project that includes some
tools used to install the application on the card.
d) Install if necessary the driver of the card reader. If you use Windows 7,
the card reader is detected automatically by the operating system. If you
use Windows XP for example, you need to install the driver from a CD or
Internet.
II. Development steps
II.1 import the eclipse project:
a) Unzip the project that is stored in this folder for example:
C:\JavaCard\[Link].
b) Launch Eclipse.
c) Import the eclipse project
C:\JavaCard\JSR268TK\JSR268TK\JSR268TK-2 as in the following :
File Import General Existing Project into WorkSpace Browse
In our example, we import the following folder:
C:\JavaCard\JSR268TK\JSR268TK-2. Choose the folder JSR268TK-2 and click
OK.
These steps are shown through the following windows:
2 Java Card Classic Edition- August 2012
S. Bouzefrane
Click on the menu File and then on Import item.
Click on “+” that is near General Click on Existing Projects into Workspace
3 Java Card Classic Edition- August 2012
S. Bouzefrane
Click on Browse, find the folder JSR268TK-2 and click on OK.
Click on Finish
4 Java Card Classic Edition- August 2012
S. Bouzefrane
You must have this window. To show the packages of JSR268TK-2 project,
click on “+”.
In the following window, you have different parts of the project. It includes
some scripts (tools) necessary to install an applet and then to interact with it
from the terminal.
5 Java Card Classic Edition- August 2012
S. Bouzefrane
[Link]: includes three scripts
deleter: to delete an existing applet.
loader: to load an applet into the card.
run: to launch a program running in the
terminal.
[Link]: allows to configure the
card reader by inserting its name in this xml file.
[Link]: contains the applet
[Link] : compiles [Link] and
generates the file [Link] tha will be
installed on the card. This file contains the AID of
the applet and the one of the package to which
belongs the applet.
[Link] : is the Java program that
interacts with the card from the terminal
6 Java Card Classic Edition- August 2012
S. Bouzefrane
II.2 Configuration and implementation steps :
a) Modify [Link] file but typing the appropriate card-reader
name.
b) Write the program of the applet ([Link]).
c) Compile the applet.
d) Write the program of the terminal ([Link]).
e) Install the applet on the card and launch the client on the terminal.
a) Configuration of [Link]
- The first step consists in modifying the file [Link] by inserting
the name of the card reader. For this purpose, you need to find the exact name of
the reader by accessing to the register base. We obtain it as in the following:
Start Button Execute Type: regedit
The name of the card reader is found in the following path:
Click on « + » behind Hkey local machine + software +
Microsoft + cryptography + calais + readers
Double-click on Device
Drug and drop the name
(clrt/c, ctrl/v)
7 Java Card Classic Edition- August 2012
S. Bouzefrane
- Double-click on the file [Link] to open it and to insert the name
of the card reader.
- Save the modifications with Ctrl/S.
Put the name of the CAD
between </cad> and </cad>
without adding spaces between
the tags.
Here is a list of the names
of CADs in comments.
8 Java Card Classic Edition- August 2012
S. Bouzefrane
b) Write the code of the applet [Link].
Double-click on the file [Link] to open it. You have an example
integrated with the project JSR268TK-2, but you can modify the integrated
code. In this case, you need to save the new code with Ctrl/S.
Here is the applet to
possibly modify
[Link]
declaration of constants
Methods: install() ,
select(), deselect().
Method process(): deals with
APDU commands
According to the INS code, a
method is triggered.
Implementation of the
methods.
If you click on « + » near [Link], you find three files:
- [Link] : is the applet to install on the card
- [Link] : is used to configure the card (don’t modify it).
- [Link] : contains the AID of the applet and the AID of the package. It
is used to generate the CAP file that will be installed on the card.
c) Compile the applet
To compile the applet, perform the following steps:
- Right-click on the file [Link]
9 Java Card Classic Edition- August 2012
S. Bouzefrane
- Select Run As
- Click on Ant Build
If there is no error, a CAP file is generated from [Link]. It
remains only to load the file on the card and to run the client.
d) Write the client program (terminal):
-Double-click on the file [Link] to open it.
- You have the following window:
10 Java Card Classic Edition- August 2012
S. Bouzefrane
Declaration of constants
Declaration of the applet AID
To compile and run the client:
-Click on « + » near [Link].
- Right-click on the file [Link].
- Select Run As.
- Click on Java Application.
11 Java Card Classic Edition- August 2012
S. Bouzefrane
At this stage, check only if the compilation is correct because the execution will
generate errors since that the applet is not yet installed.
e) Installation of the applet on the card
- To load the CAP file on the card:
Click on « + » near the package bin.
Right-click on the file [Link]
Select Run As
Click on Ant Build
12 Java Card Classic Edition- August 2012
S. Bouzefrane
- The file [Link] will execute three scripts to:
delete : delete the applet if it already exists in the card.
load : install the CAP file generated from [Link].
run : run the client [Link] to send APDU commands to the
applet.
Each time the applet is modified, it needs recompilation and installation on the
card.
13 Java Card Classic Edition- August 2012
S. Bouzefrane
14 Java Card Classic Edition- August 2012