Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting a ShareableInterfaceObject

818687May 16 2011 — edited May 16 2011
Hi,

I have this (pseudo) code for getting a Shareable IO:
    public class MyApplet extends Applet implements ToolkitInterface, ToolkitConstants 
    {
        public static MyServices MyServer;
        public MyApplet()
        {
          ...
         InitServer();// does not work here
        }
        public void processToolkit(byte event)
        {
         ...
         //InitServer();// works here
        }
        public static void InitServer()
        {
	   if(null==MyServer)
	   {
		AID serverAID=JCSystem.lookupAID(MyServerAid,(short) 0, (byte)MyServerAid.length);
		if(null!=serverAID)
		{
			MyServer=(Services)JCSystem.getAppletShareableInterfaceObject(serverAID,(byte) 0);
			if(null==MyServer)// Still null!!!
			{PrintMessage(CANT_CREATE_SERVER);}
		}
		else
		{ PrintMessage(CANT_FIND_SERVER_APPLET);}			
	}
}
My problem is that if the call to InitServer is in MyApplet's ctor, after the call MyServer is still null, whereas if the call to InitServer is in processToolkit, MyServer gets initialized properly and can be used further in the program.
Where is the problem and how can I fix this?
Maybe it matters where in the applet I ask for a SIO, maybe I should not do it in the code that gets executed during installation?

Thank you

Edited by: 815684 on May 16, 2011 2:57 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 13 2011
Added on May 16 2011
8 comments
156 views