在cmd或Powershell中,我执行java -jar file.jar(javaw不返回任何内容,但也不运行程序)。
它使用swing,当我运行它时:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: javax.swing.JDialog.setAutoRequestFocus(Z)V
at file.fileView.initComponents(fileView.java:852)
at file.fileView.<init>(fileView.java:42)
at file.fileApp.startup(fileApp.java:50)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
它说他们不是.requestFocus的方法。
这是使用Netbeans自动生成的,它在Netbeans中运行良好。但是,它不在cmd / powershell中。
谢谢,
Justin W。
答案 0 :(得分:2)
我相信你在netbeans中使用java 7,并且你从命令行使用旧版本的java。 setAutoRequestFocus
是java 7的新功能。