Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming for Java Card 3 platform in Eclipse

I've wrote programs for Java Card 2.2.2 in Eclipse using EclipseJCDE plugin and Java Card 2.2.2 Development Kit.

Now I want to write programs for my smart card that is a Java Card 3.0.1 Classic Edition, but I don't have any idea how I can do it!

Can I wrote my programs in Eclipse now or I need a new plugin?

As far as I know I must download a new development kit for this new platform. So I searched Oracle. Some where it is mentioned that :

The Java Card 3 platform consists of versions 3.0, 3.0.1 and 3.0.4 of the specifications and versions 3.0.1, 3.0.2, 3.0.3 and 3.0.4 of the development kit.

So I downloaded the Java Card 3.0.1 specification and Java Card 3.0.3 development kit. But it is not really a development kit! It is a .jar file only!

What shall I do with this .jar file? Should I import it as library in my project along with the libraries of JC 2.2.2?

Or I must copy it in the bin directory of the previous development kit?

I'm really confused about it! Should I add another plugin for Eclipse? Or I must change mu IDE?

Why JC 3.0.3 Development kit is not similar with JC 2.2.2 Development kit?

BTW, I add it to the JAR file libraries in my project, but it contains some weird classes that I didn't see them in JC 3.0.1 API Specifications! And it doesn't contain any framework or APDU or ... class!

What shall I do to be able write programs for Java Card 3.0.1? and how can I convert them to .cap file? (As far as I know I can't use the converter anymore, Is it right?)

enter image description here

like image 922
Jean Avatar asked Feb 25 '15 12:02

Jean


2 Answers

To develop for Java Card target 3.0.1 in Eclipse (on any platform):

  1. Get Java Card 3.0.3 development kit (JCDK 3.0.3 implements specification 3.0.1). You can get it here. Alternatively you can download it from Oracle web page, but then you will need Windows machine to install .jar and get its contents.
  2. Download Java Card 3.0.1 specification (java_card_kit-3_0_1-doc-spec-rr-15_may_2009.zip). Extract its contents.

  3. In Eclipse right-click on your project "Build Path --> Add External Archives..." and add lib/api_classic.jar from the 3.0.3 development kit directory. This will enable code completion and fix potential import errors.

  4. In Eclipse right-click on api_classic.jar --> "Properties --> Javadoc location path:" and specify javacard_specifications-3_0_1-RR/classic/api_classic/ from the 3.0.1 specification directory. This will enable javadoc for Java Card API calls.

  5. To convert your project's .class files to .cap files use ant-javacard. Run ant from the directory where build.xml and ant-javacard.jar is located. Here is build.xml example:

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="Hello World" default="Hello" basedir="."> 
    <target name="jcpro">
    <taskdef name="javacard" classname="pro.javacard.ant.JavaCard" classpath="ant-javacard.jar"/>
    </target>
    <target name="Hello" depends="jcpro">
    <javacard>
    <cap jckit="jc303_kit/" aid="01020304050607080900" output="testjcard.cap" sources="workspace/testjcard/src/testjcard/">
    <applet class="testjcard.JTest" aid="0102030405060708090005"/>
    </cap>
    </javacard>
    </target>
    </project>
    

The build.xml can also be added under your project in Eclipse.

  1. Upload the produced .cap file into the smart card using gp.jar from GlobalPlatformPro:

    java -jar GlobalPlatformPro/gp.jar -delete 0102030405060708090005
    java -jar GlobalPlatformPro/gp.jar -delete 01020304050607080900
    java -jar GlobalPlatformPro/gp.jar -install testjcard.cap

like image 84
FaST4 Avatar answered Sep 21 '22 08:09

FaST4


The .jar is actually just an installer. You'll have to run it to get the real runtime using java -jar <file.jar>. Then you should get the SDK.

like image 23
Maarten Bodewes Avatar answered Sep 17 '22 08:09

Maarten Bodewes