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