Forum Stats

  • 3,826,586 Users
  • 2,260,667 Discussions
  • 7,897,010 Comments

Discussions

Applet comprising multiple packages

802670
802670 Member Posts: 9
edited Nov 16, 2010 5:38PM in Java Card
Hi.

In the book "Java Card Technology for Smart Cards" by Zhiqun Chen in the 3.9 there is application developement process is described and something mentioned that got my attention:

"*If an applet comprises several packages, a CAP file and an export file are created for each package*".

Could anyone please show an example of an applet comprising several packages?

I am not sure I understand the conception. Right now in my developement I have a few packages and a couple of applets in each package, but not the other way around. How can applet comprise a package?

If there is such an example, a new question it raises: how can applet's objects from one package access its own methods from other package (unless it's in class that implements Shareable)? Would the java card firewall allow it? Because it seems to me, it shouldn't, since the other package means another context.

Please, help me out here. Thanks.
Tagged:

Best Answer

  • safarmer
    safarmer Member Posts: 2,829
    Answer ✓
    An applet will only ever be in one package. What they are referring to, is an applet that uses several packages. Each package is a separate CAP file. If a package does not have an applet it is a library package and is treated slightly differently (check the JCDK documentation for an explanation). Each package that is used by another package needs an EXP file to convert against. A library package is treated a little differently by the firewall. The instance data contained in it belongs to the applet context that created.

    Cheers,
    Shane

Answers

  • safarmer
    safarmer Member Posts: 2,829
    Answer ✓
    An applet will only ever be in one package. What they are referring to, is an applet that uses several packages. Each package is a separate CAP file. If a package does not have an applet it is a library package and is treated slightly differently (check the JCDK documentation for an explanation). Each package that is used by another package needs an EXP file to convert against. A library package is treated a little differently by the firewall. The instance data contained in it belongs to the applet context that created.

    Cheers,
    Shane
  • As quoted by thread's author the phrase in the book (famous book in java card community then?), they use the verb "comprise" and normally, we understand that, an applet contains some java packages.
    I'll totally agree with safarmer if we explain the phrase such as what he/she did. In the java card world, it's meaningful and logically correct.

    Best regards,
    BinhLH
    Jean-Damien LEBUI
  • safarmer
    safarmer Member Posts: 2,829
    Hai-Binh LE wrote:
    famous book in java card community then?
    It is the only useful book I have found on the topic. Granted I have not looked very hard, but this book was enough to get me started.

    Cheers,
    Shane
  • 802670
    802670 Member Posts: 9
    Thank you very much for all your answers. It makes sense now.

    One more question. If I write an applet and a library package. If I install it on the card where other applets are already installed (or will be installed), is it possible for other applets to access my library package?
    So, my question is, is library package linked somehow with one applet or is it common and anyone can use it?

    Thank you.
  • safarmer
    safarmer Member Posts: 2,829
    Pyotr Petrov wrote:
    One more question. If I write an applet and a library package. If I install it on the card where other applets are already installed (or will be installed), is it possible for other applets to access my library package?
    So, my question is, is library package linked somehow with one applet or is it common and anyone can use it?
    To load a CAP file (package) onto a card, all externally referenced packages must already be on the card. When you convert your packages, you need to have the EXP files for any libraries available so that you can link to them. The JCDK packages are (mostly) handled for you so this is why you do not see this for those packages.

    Any package loaded after your library could technically access the package. Just remember than any instance data is owned by the applet that created it and is not accessible across the firewall.

    Cheers,
    Shane
    safarmer
This discussion has been closed.