0% found this document useful (0 votes)
2 views3 pages

Java Card Compile Upload Process

The document outlines the process for developing JavaCard applets using NetBeans, including installation of necessary software such as Java SDK, GPShell, and Java Card Development Kit. It provides detailed steps for configuring project settings, modifying build files, and converting applets for upload to smart cards. Additionally, it includes usage hints for compiling and testing the applets within the NetBeans environment.

Uploaded by

Mohamed Moustafa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Card Compile Upload Process

The document outlines the process for developing JavaCard applets using NetBeans, including installation of necessary software such as Java SDK, GPShell, and Java Card Development Kit. It provides detailed steps for configuring project settings, modifying build files, and converting applets for upload to smart cards. Additionally, it includes usage hints for compiling and testing the applets within the NetBeans environment.

Uploaded by

Mohamed Moustafa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

public:javacardcompilation2 [PetrS] [Link]

JavaCard applet development with NetBeans


© 2010 by LaBAK FI MUNI

Installation process
Following software will be used

NetBeans 6.8 or later ([Link] [[Link]


Java 2 SDK, Standard Edition (J2SE), v 1.3.1_20 ([Link] [[Link]
/products/archive/j2se/1.3.1_20/[Link]])
GPShell 1.4.2 ([Link] [[Link]
AntTask ([Link] [[Link]
Java Card Development Kit 2.2.2 ([Link]
[[Link]

1. Install NetBeans
2. Install Java 2 SDK (JDK 1.3)
3. Install JavaCard 2.2.2
4. Install GPShell
5. Create new java project
6. Set configuration parameters in “nbproject/[Link]”
[Link] - path to Java Card Development Kit
jc.export_files - path to Java Card export files (for verifier), usually ${[Link]}\\api_export_files
[Link] - path to GPShell
[Link] - path to GPShell executable

Example of configuration:

# Java Card Development Kit home directory


[Link]=c:\\Program Files\\java_card_kit-2_2_1
jc.export_files=${[Link]}\\api_export_files
# GPShell positioned in project_path\bin\GPShell-1.4.2
[Link]=${basedir}\\bin\\GPShell-1.4.2
[Link]=${[Link]}\\[Link]

[Link]=true
[Link]=false
[Link]=true
[Link]=\
${[Link]}

[Link]=Sample Java Card project


[Link]=SmartHelloWorld

... rest of [Link] file automatically generated for new project

1. Modify file '[Link]' to contain following Ant tasks

[Link]

<?xml version="1.0" encoding="UTF-8"?>


<project name="SmartHelloWorld" default="default" basedir="." xmlns:j2seproject3="[Link]
<description>Builds, tests, and runs the project SmartHelloWorld.</description>
<import file="nbproject/[Link]"/>
<target name="-post-init">
<path id="jc-tasks" >
<pathelement path="lib//[Link]"/>
</path>
<taskdef name="apdutool"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="capgen"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="convert"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="verifyexport"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="verifycap"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="verifyrevision"
classname="[Link]"
classpathref="jc-tasks" />
<taskdef name="scriptgen"
classname="[Link]"
classpathref="jc-tasks" />

<path id="jc-classpath" >


<pathelement path="${[Link]}/lib/[Link]"/>
<pathelement path="${[Link]}/lib/[Link]"/>
<pathelement path="${[Link]}/lib/[Link]"/>
<pathelement path="${[Link]}/lib/[Link]"/>
<pathelement path="${[Link]}/lib/[Link]"/>

1 of 3 26-Sep-10 10:00 AM
public:javacardcompilation2 [PetrS] [Link]

<pathelement path="lib//[Link]"/>

<pathelement path="."/>
</path>
</target>

<target name="convert" depends="init">


<copy todir="${[Link]}">
<fileset dir="${jc.export_files}">
<filename name="**/*.exp"/>
</fileset>
</copy>

<convert
dir="${[Link]}"
Configfile="${[Link]}/com/sun/javacard/samples/HelloWorld/[Link]"
nobanner="true">
<classpath refid="jc-classpath"/>
</convert>
<verifycap Verbose="true" CapFile="${[Link]}/com/sun/javacard/samples/HelloWorld/javacard/[Link]">
<exportfiles file="${jc.export_files}/java/lang/javacard/[Link]" />
<exportfiles file="${jc.export_files}/javacard/framework/javacard/[Link]" />
<exportfiles file="${jc.export_files}/javacard/security/javacard/[Link]" />
<exportfiles file="${jc.export_files}/javacardx/crypto/javacard/[Link]" />
<exportfiles file="${[Link]}/com/sun/javacard/samples/HelloWorld/javacard/[Link]" />
<classpath refid="jc-classpath"/>
</verifycap>

</target>

<target name="jar" depends="init,compile,convert">


</target>

<target name="run-script" depends="init">


<exec executable="${[Link]}">
<arg value="scripts\\helloInstallGP211_JCOP41_cap.txt"/>
</exec>
</target>
</project>

Developing new Java Card applet

1. Change Java build platform from 1.6 (default) to 1.3


Project_name→Libraries→R-Click→Properties→Manage Platforms→Add platform→point to JDK 1.3 folder
Choose JDK1.3 from list in Properties→Libraries→Java Platform
2. Write/Replace code with JavaCard applet (e.g., [Link] [[Link]
3. Add JavaCard libraries
Project_name→Libraries→R-ClickAdd library→Create library
javacard SDK folderlib/[Link]
javacard SDK folderlib/[Link]
javacard SDK folderapi_export_files
add created JavaCard library to project
4. Try to compile project (Project should compile without errors)

Converting and uploading applet to smart card

Create 'helloInstallGP211_JCOP41_cap.txt' script file for GPShell suitable for your card. Example for JCOP 4.1 cards:

# Usable for:
# NXP JCOP 4.1, 3.1 and 2.1 cards

mode_211
enable_trace
establish_context
card_connect
select -AID a000000003000000
#select -AID A000000018434D00

open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel

delete -AID a00000006203010c0101

delete -AID a00000006203010c01


install -file build/classes/com/sun/javacard/samples/HelloWorld/javacard/[Link] -sdAID A000000018434D00 -nvCodeLimit 4000
select -AID a00000006203010c01
send_apdu -APDU B040000009010203040506070809

card_disconnect
release_context

Try to rebuild your project (Run→Clean and build project). Project is compiled and converted, but not uploaded to smart card (use until
java card applet compile and convert without error)
Following steps should occur with ooutput visible in NetBeans output console:
1. Build of java card application, *.jar file(s) are created
2. Conversion to java card format (convert task), *.jar and *.cap files are created in project_path\build\… directory

Try to test your project (Run→Test project). Use when applet is compiled and converted without error.
Following steps should occur with output visible in NetBeans output console:
1. Build of java card application, *.jar file(s) are created

2 of 3 26-Sep-10 10:00 AM
public:javacardcompilation2 [PetrS] [Link]

2. Conversion to java card format (convert task), *.jar and *.cap files are created in project_path\build\… directory
3. Upload to smart card (GPShell output)

Usage hints

Both compilation and testing can be executed from NetBeans (Build or Test commands from menu) and are handled by Ant and
configured in “[Link]”.
When compilation is done (compiled files are in build/classes/), task “convert” is executed and performs conversion and verification.
Converted file can be found in build\classes\com\sun\javacard\samples\HelloWorld\javacard. This action can be configured in task
“convert” in [Link].
Testing executes script “scripts/helloInstallGP211_JCOP41_cap.txt” in GPShell and tries to install HelloWorld on compatible Java Card.
This action can be configured in task “run-script” in [Link].

public/[Link] · Last modified: 2010/09/26 09:57 by petrs


Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0
Unported [[Link]

3 of 3 26-Sep-10 10:00 AM

You might also like