我有我的 JNLP 应用程序,它与 Oracle JDK 完美配合。但是当我尝试使用 openJDK 1.8.0.252 和 IcedTea WS(openJDK 默认提供)运行它时。
我看到我的应用程序可以使用多个实例启动,尽管有 SingleInstanceListener 的实现。
我从来没有在控制台中打印过记录器“Start newActivation method”。我还想(尝试)使用参数启动应用程序。谁能帮我这个
代码 ::
// Code from Main class
private void startSingleInstance() {
log.info("Initializing single instance Web Start");
boolean didAddListener = false;
final SingleInstanceListener singleInstanceListener = new SingleInstanceListener() {
@Override
public void newActivation(String[] args) {
log.info("Start newActivation method");
log.info("newActivation(args:{}) in env {} Frame visible? {}",
new Object[] {args, System.getProperty("app.environment"), frame != null ? frame.isVisible() : false});
if (args.length > 1) {
// some logic
}
SwingHelper.frameToFront(frame);
}
};
try {
SingleInstanceService singleInstanceService =
(SingleInstanceService) ServiceManager.lookup("javax.jnlp.SingleInstanceService");
log.info("singleInstanceService {} ",singleInstanceService);
// add the listener to this application!
log.info("Add singleInstanceListener");
singleInstanceService.addSingleInstanceListener(singleInstanceListener);
didAddListener = true;
} catch (UnavailableServiceException e) {
log.info("Unable to register single WebStart instance (Not Web Start environment?).");
}