jnlp的SingleInstanse

//实现SingleInstanceListener接口
class SISListener implements SingleInstanceListener
{
    public void newActivation(String[] params)
    {
        //处理传入参数
    }
}
//获取服务
SingleInstanceService sis; 
try
{ 
    sis = (SingleInstanceService)ServiceManager.lookup("javax.jnlp.SingleInstanceService");
} 
catch (UnavailableServiceException e) 
{ 
    sis=null; 
}
//程序启动时注册SingleInstanceListener
SISListener sisL = new SISListener();
sis.addSingleInstanceListener(sisL);
//程序退出时移除SingleInstanceListener
sis.removeSingleInstanceListener(sisL);
System.exit(0);

Comments are closed.