Results 1 to 6 of 6

Thread: Java Card - Windows programming

  1. #1
    Join Date
    Nov 2008
    Posts
    1,192

    Java Card - Windows programming

    Introduction :

    The JavaCard appeared on the market for smart cards around 1996. They have the advantage of being able to develop applications using simple language, open and understandable by a large number of developers. They may be in the form of SIM card, bank card, access cards, etc. It sold close to one billion Java SIM cards per year worldwide. In 2009, over a billion Java SIM cards were in circulation in the world and more than 5.5 billion smart card JavaCard. This technology is compatible with existing smart card standards, allows you to run Java applications called applets on smart cards with low memory (a few tens of KB). Several applets can co-exist on the same JavaCard. The application Moneo, for example, is an application that coexists with the application Europay MasterCard Visa (EMV) on a credit card. You can familiarize yourself with the JavaCard a free development environment for developing applets, develop client applications and test them using a simulator card.

    Specifications :

    The JavaCard meet ISO7816 standard introduced in 1988. The latter describes (among others) the communication interface between the card and terminal. The reader provides the supply voltage and clock frequency of 3.5 MHz. The exchange of data is provided by a serial half-duplex flow between 9600 and 115200.

    The APDU: Application Protocol Data Unit :

    The exchange between card and terminal are using APDUs (sequence of bytes following the format defined in the standard ISO7816-4).
    • CLA = byte class defined by ISO 7816 provides a number of control information (eg for maps 0xBC vital for SIM cards 0x0A, 0x00 for Mastercard / Visa)
    • Instruction byte INS =
    • P1 = 1 parameter
    • P2 = Parameter 2
    • Lc = data size (0x00 if no data)
    • = The maximum size of data to answer

    The card responds by sending the response data (if any) followed by a status word coded on 2 bytes (named SW1 and SW2). Generally, SW1 indicates the type of response and SW2 provides additional information.

  2. #2
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Java Card - Windows programming

    Identification applets :

    Applets are identified by an AID (applet ID) composed of 5-16 bytes. The first five correspond to the ID of the application provider (RID) and the following identifies the application. The RID is provided by the ISO and DIN are reserved for development. To contact it, an applet must first be selected using the following APDU via the SELECT.

    Limitations of the JavaCard Virtual Machine 2.x :

    The framework JavaCard 2.x is a subset of Java. It only supports the following:
    • primitive types boolean, byte, and short
    • the one-dimensional arrays
    • packages, classes, interfaces, exceptions
    • inheritance, virtual objects, overloading
    • object creation (new) but only in its constructor / method of installation (so no object creation in runtime)

    Thus types long, double, float, char, String and multidimensional arrays are not allowed. The object creation (new) in runtime is technically possible but not recommended because Javacard has no garbage collector. In addition, the onboard memory is very low, there is no guarantee that there will be enough memory in runtime to create a new class instance.

    To develop a JavaCard applet and a client application, we will install a development environment. The tools usually required are :
    • Java Card Development Kit 2.2.2
    • development environment Eclipse version 3.2.2
    • Eclipse integration plugin version 0.1-JcDe

    These tools require Java version 1.5 or higher.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Java Card - Windows programming

    Installation :

    First, unzip the archive java_card_kit-2_2_2-windows.zip in the folder of your choice (C: \ JCDK in this tutorial). Unzip then four archives of the C: \ JCDK \ java_card_kit-2_2_2 into the same folder. This way you should see (among others) the following folders:

    C:\JCDK\java_card_kit-2_2_2\bin:contains tools JCDK (simulator, ...)
    C:\JCDK\java_card_kit-2_2_2\lib:contains the libraries of JCDK
    C:\JCDK\java_card_kit-2_2_2\jc_specifications\specs\api\html:contains API JCDK (very useful)


    To use the tools of JCDK command line, you must define two environment variables: JAVA_HOME contains the path to Java and JC_HOME containing the path to JCDK. It may then be useful to create a batch script to initialize these variables and update the PATH variable. For this tutorial, we create the script setvars.bat following:
    Code:
    @echo off set JAVA_HOME=c:\java set JC_HOME=c:\JCDK\java_c~1 set PATH=%PATH%;%JC_HOME%\bin
    Then install Eclipse: unzip the archive eclipse-SDK-3.2.2-win32.zip to a folder of your choice (C: \ Program Files \ Eclipse in this tutorial).
    Install the plugin EclipseJCDE: Place the contents of the archive file plugins-eclipse-0.1.zip JcDe in the Eclipse plugins folder (C: \ Program Files \ eclipse \ plugins in this tutorial). At this stage, we have a development environment for creating JavaCard Applet, to simulate and create client applications.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,192
    Coding of a JavaCard applet :

    We will create in this tutorial a basic applet. To do this, start Eclipse, from the File menu, then to New Other ... :


    Then select Java Card Project:


    Then click the Next button. Then give the project a name. We call it "Tutorial JavaCard"


    Then click on the Finish button. You should see the following error message:


    Then enter the folder has been installed the Java Card Development Kit 2.2.2, then click the OK button:


    At this stage, we just created our project JavaCard applet. We will now create our applet JavaCard. To do this, go to the File menu, then to New Other ... Then select "Java Card Applet" then click the Next button:


    Then give a name to the package and the applet. We call them respectively "MyPackage" and "MonApplet"


    Then click on the Finish button. We just generate the skeleton of our applet:


    Right click on the package MyPackage, Java Card Tools Set Package AID:


    Press the OK button. The IDA package must be a prefix of the applet AID.

    The install method is called when instantiating the applet in the JavaCard. It instantiates MonApplet our class and saves. The instantiation of other objects (new statement) is allowed only in this method (or in the constructor of the class). The process method is the main method of the applet. It will be called each time the card receives an APDU, passed as a parameter of the method.

  5. #5
    Join Date
    Aug 2010
    Posts
    2

    Re: Java Card - Windows programming

    Once I have written the applet, when should i start the CREF? and then what about the setvars.bat??? where should i put it???

  6. #6
    Join Date
    Dec 2007
    Posts
    2,291

    Re: Java Card - Windows programming

    Below is the command to start the CREF from comman line:

    C:\Java_ME_platform_SDK_3.0\bin\cref -i apps\SATSAtrial\sat.eeprom
    You can get more information about from where to start and when to start the CREF and the setvars.bat and by reading some suggestions given here in this topic - Simulation Tools in Java Card

Similar Threads

  1. Help with java programming term
    By cloud101 in forum Software Development
    Replies: 1
    Last Post: 06-02-2012, 01:45 PM
  2. Java programming
    By overlord94 in forum Software Development
    Replies: 1
    Last Post: 07-10-2011, 07:45 PM
  3. Java Programming using Adventnet SNMP Java API
    By ROCKING_Suhas in forum Software Development
    Replies: 5
    Last Post: 17-07-2010, 06:52 AM
  4. What is RMI in java programming?
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 12-03-2010, 08:37 PM
  5. How to Start programming in JAVA ?
    By Keegan in forum Software Development
    Replies: 11
    Last Post: 22-12-2008, 02:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,581,970.76454 seconds with 17 queries