Code sharing between applets

Hi,
I'm currently using Eclipse and JCOP plugin for applet development, and I'm looking for solutions on how to share custom libraries between applets. I'm particularly not looking for interface sharing between applets, but more how to organize the source code so I can include common custom classes in different applets (e.g. generic ASN1 parsing library, signature library etc)
Thank you for any feedback.

Thanks for the pointer! I also found this thread:
https://forums.oracle.com/thread/2217928?start=0&tstart=0
which cover the same topic with code examples to be very useful.
But I have stumbled upon a couple of problem wrt this approach which I can't quite isolate:
1. I've got a shell script which basically "tags" a package before build with the SVN version number, and if there are local modifications. This code is auto-generated in a file called svnversion.java inside commonlib package:
package commonlib;
public class svnversion {
  public static final byte[] TAG = {(byte) 0x00 ,(byte) 0xFB ,(byte) 0x3F } ;
  public static final boolean MODIFIED = true ;
When this code was in the same package as the applet, I had no problem accessing the TAG byte array, but after separating the applet and the commonlib in two separate packages, I get SW 0x6f00 whenever I touch the TAG byte array from my applet. I can access the MODIFIED variable, but not the TAG byte array.
(EDIT: Since commonlib declare TAG as a static final byte array, and final cannot be set to null upon release, maybe this is the cause for my memory leaks?)
2. I try to keep everything in commonlib static, and I've added an install() and release() hook in commonlib which keeps track of reference counter and acquire and release memory. Upon release I set every static variable to null. And I call commonlib.install() from the applet, and use AppletEvent and do commonlib.release() upon uninstall. But still it seems I fail to clean-up properly, because I end up in situations where I'm unable to delete the card content - presumably because a memory leak. So I have a few questions related to that:
a) How do I debug memory leaks?
b) In commonlib, if I do:
public class Common {
     private static DESKey des1Key = null;
     private static short refCount = 0;
     public static void install() {
          refCount++;
          if (des1Key == null)
               des1Key = (DESKey) KeyBuilder.buildKey(KeyBuilder.TYPE_DES, KeyBuilder.LENGTH_DES, false);
public static void release() {
     --refCount;
     if (refCount == 0)
          des1Key = null;
Is it a correct assumption that I need to set des1Key to null, because it is declared as static?
c) Does the following code snippets allocate memory, which needs to be freed?
md = MessageDigest.getInstance(MessageDigest.ALG_SHA_256, false);
and
rsaCipher = Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);
d) Say commonlib should hold one RSA key, but at install time we do not know the key size (actual size shall be requested by client). I chose this approach:
public class RSAlib {
     public static KeyPair rsaKeyPair = null;
     public static Cipher rsaCipher = null;
private static short refCount = 0;
     public static void install() {
refCount++;
          if (rsaCipher == null) {
              rsaCipher = Cipher.getInstance(Cipher.ALG_RSA_NOPAD, false);  }
     public static void release() {
          --refCount;
          if (refCount==0) {
               rsaCipher = null;
               rsaKeyPair = null;
public static void createRSAKeyPair(short keySize) {
     switch(keySize) {
     case (KeyBuilder.LENGTH_RSA_1024):
     case (KeyBuilder.LENGTH_RSA_2048):
          break;
     default:
          ISOException.throwIt(SW.CRYPTOGRAPHIC_ERROR);
     try {
          JCSystem.beginTransaction();
          rsaKeyPair = new KeyPair(KeyPair.ALG_RSA_CRT, keySize);
          JCSystem.requestObjectDeletion();
          JCSystem.commitTransaction();
     } catch (Exception e) {
          JCSystem.abortTransaction();
Is this correct usage of garbage collection (I know my JCOP card support it), and will this work in context of a commonlib?

Similar Messages

  • Navigating between applets from the same signed jar (trusted CA) gives err

    See [http://www.chrisnewland.com/java-7-update-21-signedunsigned-error-switching-between-applets-in-the-same-signed-jar-trusted-ca-339] for my investigations so far.
    Clicking a link to navigate between applets contained in the same signed jar (signed by a trusted CA) pops up an error dialog complaining about a signed/unsigned code mix.
    Loading each applet in a fresh browser works fine.
    If you click from applet 1 to applet 2 via a non-applet page then both applets run without problem.
    [EDIT: This is behaviour is new to 7u21]
    Edited by: Chris Newland on Apr 17, 2013 3:19 AM

    I tried that (Adding Trusted-Library true) to the jars and even the 3rd party jars.  I still get the pop up and this error:
    Exception in thread "thread applet-com/travelers/prefillapplet/PrefillApp.class-1" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)

  • TS3981 After migration files are now shared between two user accounts. How can I combine them into one account?

    After migration, from PC, files are now shared between two user accounts.I have to switch users to access files. How can I combine them into one account?

    See Pondini's  Transferring files from one User Account to another, for starters

  • How can I use home sharing between our iphones (create playlists from both accounts at once)

    How can I use home sharing between our iphones, so that we can create playlists with songs from both of our libraries?  We share a Macbook Pro (separate accounts) and each have the new iphone, but when I have my iphone and try to create a new playlist, I can only grab songs from one account.  Is there a way to create a playlist using both accounts since we are sharing?
    Does it have to be created within iTunes first on our Mac?

    The short answer: because Home Sharing isn't designed for sharing apps, and apps aren't designed to be shared.
    The longer answer:  Think of it like this...
    You download some music in iTunes.  With Home Sharing, another user can listen to it by streaming it over the network.  But the data itself is on your computer.  If you turn off the computer or take it off the network, the other user can't access it.
    But if you send another user the app, they aren't just streaming the data- they installed it on their iOS device.  Because they weren't the one that purchased it, such a transfer could easily be considered "piracy" or "stealing," and nobody likes that (least of all, Apple). 
    When iTunes sees this app, it obviously recognized it, as if saying, "Hey, how did you get this app on your device, if I have no record of you purchasing/downloading it from the iTunes store?"
    post edited to correct spelling errors

  • Difference Between Applet and Swing

    Difference Between Applet and Swing

    The advantages and disadvantages of both applets and Swing are the small fluffy elephants you get inside of every box. They're quite well trained and can skeletonize your neighbors' annoying pets upon command.

  • ITunes Library shared between computers?

    I have an iMac (OSX Lion) with two user accounts that are both sharing the same iTunes Library.  We now have a Macbook Air with the same user accounts.  The Macbook Air obviously does not have the same hard drive space and I therefore did not choose to migrate the library to the Air...What is the best way for each user to access the shared iTunes folder from the iMac?  I would like to do this while on the same LAN as well as remotely if possible.
    I assume that simply setting iTunes up for "Sharing" will handle the local area question, but what about while we are away from home?  I assume that iCloud with iTunes Match would be the only answer?

    Rented movies cannot be shared between computers. They can only exist on a single device at a time, and can only be moved from a computer to a player such as an iPod, iPhone or Apple TV. You cannot move a rental from one computer to another.
    And yes, actually they do say that, in the Rentals FAQ, among other places.

  • Can data from Apps be shared between family members with iCloud Family Share?

    I'd like to know if data from Apps can be shared between family members with Family share in iCloud

    no, unless the app has a sharing setting.

  • I have multiple devices and don't want everything shared between them. How do I fix that?

    I have and iphone and three ipods in my home. They are all connected to my apple id and everything ends up being shared between them. Can I make seperate accounts for each of them, but have them all attached to my credit card? Thanks for any help!!!

    If you have a Mac (don't know about Windows), you can disable automatic syncing in iTunes > Preferences > Devices:
    That way, you can manually do it by plugging in the device and launching iTunes.

  • All my contact are being copied to my friend's iphone and i also am getting his contacts on my phone,when i delete a contact it also deletes it from his phone,we are sharing the same apple ID. How can i stop our contacts from being shared between us

    All my contact are being copied to my friend's iphone and i also am getting his contacts on my phone,when i delete a contact it also deletes it from his phone,we are sharing the same apple ID. How can i stop our contacts from being shared between us

    Everything that you have checked in your icloud settings will be shared between devices using the same Apple ID.  If you don't want icloud to share that information, then simply turn off that process under settings > icloud

  • I am trying to set up home sharing between my iphone 4s and mac which is running itunes 11. Both are connected to my home wifi network and using the same apple id but on the iphone app it says 'Turn on Home sharing in iTunes on your mac using account ***

    I am trying to set up home sharing between my iphone 4s and mac which is running itunes 11. Both are connected to my home wifi network and using the same apple id but on the iphone app it says 'Turn on Home sharing in iTunes on your computer or apple tv using account ***
    Does anybody have suggestions as to why this is the case?

    Understanding Home Sharing - Support - Apple
    Hope this helps.

  • Can I use home sharing between my iPhone and iPad? Or do I need to use a computer?

    I want to use home sharing between my iPhone and Ipad. So I can use the remote app. But I can't get it to work

    You can use it to share the library on your computer to the iPad, not the other way around.
    On the computer, set up homesharing in the advanced menu. On the iPad go to settings > music.

  • Can i use home sharing between my computer and my ipad?

    can I use home sharing between my computer and my new ipad (3rd generation)  if so, how.
    Thanks

    You can use it to share the library on your computer to the iPad, not the other way around.
    On the computer, set up homesharing in the advanced menu. On the iPad go to settings > music.

  • I enabled computer home sharing between my fiance's apple computer and my windows. I am able to play his music on my computer now, however I am making playlists for our wedding, and am unable to transfer any of his songs to my playlists.How can I do this?

    I enabled computer home sharing between my fiance's apple computer and my windows computer, so I now can play his music on my computer; however, I am making playlists for our wedding and am unable to transfer any of his songs to my playlists. How can I do this?

    Thanks
    Are you sure that if I use my windows log in rather than my husbands, then open itunes it won't delete all his hundreds of songs and overwrite with mine? 
    I want to maintain my own apple ID login and he wants his but without losing his songs.....
    how do i transfer the content of my itunes including apps and songs to the new computer.  There doesn't seem to be an easy explanation on here. Do I just plug my iPhone in and it will all transfer?

  • HT4527 I tried home sharing between my desk top and my lap top. My desk top is the original computer with my iTunes library. On my lap top I can only see the music I have bought from iTunes. Is this all I should see? Not my entire library?

    I have tried to install home sharing between my desk top and lap top. I can only see the music I have bought from iTunes on my lap top. Is this normal? I thought I would be able to see my entire library.

    Yes I tried that. I finally turned off all home sharing settings, shut down my desktop and found them in my account settings in the store on the cloud. So at that point I just had it download everything. But I suspect that with the ipad somehow being on, the store was saying I had already received them? Regardless, my trip today whilst running errands, I was rocking out to vintage Police music! Thank you so much for responding.

  • TS2972 is it possible to use home sharing between two users on the same computer?

    My wife and I have itunes accounts and want to be able to share music we have each bought on our accounts. We have tried setting up the home sharing on our PC but it doesn't show up on the screen. Can anyone please help?

    "Is it possible to use home sharing between two users on the same computer?"
    No. Home sharing is used to connect two running instances of iTunes across a network. When you switch users on the computer all applications running on the other profile are suspended.
    You can however share your respective media folders so that they are visible in either profile and then copy over any content that you want, or you could create a single joint library which you use when either user is logged in.
    tt2

Maybe you are looking for

  • How to do this?

    I need help with something! I know my explanation isn't the best, but I hope you can see what I'm saying. Basically, I want to build an interactive flash web application with a database. (I think) Here is what i want to do: The user is HUNGRY! 1. The

  • Google calendar sync AFTER upgrade

    I'm having a small issue after my upgrade... We use google e-mail at work.  I had previously set-up my google account using EAS.  Now that I upgraded I deleted that account and used the auto set-up, e-mail works fine, contacts seem to work fine, and

  • Source list too long!

    hey peeps, i want to remove the podcasts, radio, music store and purchased music items from my source list and be able to access them from menus or preferences. i only have the choice to disable party shuffle and video. any suggestions? thanks for re

  • Comparation between database XE and 10Gr2

    Hello everybody. I want compare the diferences between Oracle Database XE and Oracle Database 10G. I suppose that must to be a document where this comparation is done. Anybody can send me the link where it is? Thanks in advanced & regards to all.

  • Custom transformation does not run against Logical Model

    Here is the screen [http://img849.imageshack.us/img849/7411/20110530174314002.jpg|http://img849.imageshack.us/img849/7411/20110530174314002.jpg] Besides setting the object=logical, the script ran against the relational model. To prove this, have a sc