我用NetBeans创建了一个项目。我做了一个类,checkForUpdates。如果有,它会进行升级,否则它会启动主项目类。
问题是当我创建MyClassApp的对象和我启动myClass.startup()我得到了这些错误....我认为这是我的更新类,所以我尝试了一个正常的main没有任何东西,只是创建MyClassApp和启动startup(),但它得到相同的错误。
我该如何修复它?
26-set-2011 12.34.32 org.jdesktop.application.ResourceManager getApplicationResourceMap
WARNING: getApplicationResourceMap(): no Application class
26-set-2011 12.34.36 org.jdesktop.application.SingleFrameApplication initRootPaneContainer
WARNING: couldn't restore sesssion [mainFrame.session.xml]
java.lang.NullPointerException
at org.jdesktop.application.LocalStorage.getApplicationId(LocalStorage.java:195)
at org.jdesktop.application.LocalStorage.getDirectory(LocalStorage.java:234)
at org.jdesktop.application.LocalStorage$LocalFileIO.openInputFile(LocalStorage.java:330)
at org.jdesktop.application.LocalStorage.openInputFile(LocalStorage.java:76)
at org.jdesktop.application.LocalStorage.load(LocalStorage.java:138)
at org.jdesktop.application.SessionStorage.restore(SessionStorage.java:382)
at org.jdesktop.application.SingleFrameApplication.initRootPaneContainer(SingleFrameApplication.java:231)
at org.jdesktop.application.SingleFrameApplication.show(SingleFrameApplication.java:463)
我不知道是什么原因导致这个错误,但我有一个解决方案。
您可能有如下定义的类:
public class MyClassApp extends SingleFrameApplication {
...
@Override protected void startup() {
show(new MyClassApp (this));
}
...
public static MyClassApp getApplication() {
return Application.getInstance(MyClassApp.class);
}
...
}
如果你用
开始你的应用程序MyClassApp.getApplication().startup();