Reputation: 1264
I wrote in two differents projects Java Card 2.2.2 an applet Applet1
in a package firstApplet
and another applet Applet2
in a package secondApplet
.
I want to use some features of the first applet in the second one.
So in Applet2
, after adding to the second project's Java Build Path the first project, it looks like:
package secondApplet;
import javacard.framework.APDU;
...
import firstApplet.Applet1;
public class Applet2 extends Applet {
...
}
First, with the Java Card tool converter
I get a .exp
file using this command:
converter -out EXP -exportpath ..\api_export_files -applet AID Applet1 -classdir ..\..\ ... \Applet1\bin firstApplet PID 1.1
where AID
is the applet ID and PID
the package ID. It gives me a firstApplet.exp
without error.
The output of this command is:
parsing C:\ ... \bin\firstApplet\Applet1.class
converting firstApplet.Applet1
writing C:\ ... \bin\firstApplet\javacard\firstApplet.exp
but then, when I try to get the Applet2
's CAP file it returns me the error:
error : secondApplet.Applet2: class firstApplet.Applet1 not found in export file firstApplet.exp.
I don't really get what is going wrong, I thought that the .exp was well generated, am I missing something ?
Upvotes: 2
Views: 1870
Reputation: 11
Over 1,5 years late but nevertheless interesting question. Here's my answer: It is by design. If you have applets in your CAP file, your exports will not contain public classes (Specification of Javacard Virtual Machine, version 3.0.1, section 6.12 "Export Component" - last paragraph.) So in order to do what you want to do, you will need to create a library package out of Applet1. In theory, you can do that by not specifying applets when creating the CAP file for Applet1. There will be two problems with that: first the converter won't let you create such "ill-formed" files and second you would not be able to instantiate Applet1.
If you simply want Applet2 to be like Applet1 with cherries on top, the best way is to put the machinery of Applet1 into an abstract class -and in a different package-, have Applet1 and Applet2 both extend this abstract class.
Upvotes: 1