2

I'm developing a simple javacard applet using the jcdk 3.0.5u3 with Eclipse Oxygen3. If I use a simple API from GlobalPlatform like the GPSystem.getCardContentState() results in error.

I've tried to add the globalplatform.jar file from GP API v1.1 and v1.6 to the Reference Libraries part of the package explorer. I also imported the "org.globalplatform.*" into the code.

import org.globalplatform.*;

if(GPSystem.getCardContentState() == GPSystem.APPLICATION_SELECTABLE){
//Do something
}

The converter returns "export file global platform.exp of package org.globalplatform not found"

Dushyant Tankariya
  • 1,432
  • 3
  • 11
  • 17
1chenar
  • 197
  • 1
  • 15

1 Answers1

0

Java Card doesn't just require a compile stage, it also performs the linking that is usually performed as dynamic linking in the JVM of a normal Java application. Basically it orders the methods and such, and then calls the right serial ID. You don't want your Applet to contain the string names of your fields after all: it would explode the memory requirements, and dynamically looking for classes and fields is not a good idea either within such a restricted platform.

So if you call external libraries then you need to configure:

  1. the .jar file containing the .class files for the normal compiler;
  2. the .exp file which contains the an export of the mapping of the normal names and the ID of the classes and fields specific for the converted classes of the called library;

If it is not already present on the card, you may also need the version specific .cap file for uploading. However, the GP functionality is should already be present on the card.

The ID's are only unique for a specific .cap file / preloaded byte code. This is why you always need the right .exp file for the code that is loaded. If another field is added, the ordering is different and the wrong fields would be linked, if the linker executes at all. So having the right .exp file is a requirement for correct conversion to .cap for your application / library.

For the JCDK I think you just need to configure the right -exportpath, as the GP should be included with the JCDK.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263