javanetbeansnosuchmethod

Java NoSuchMethodError for javax.swing.JDialog.setAutoRequestFocus from Command Line


In cmd or Powershell, I do java -jar file.jar (javaw doesn't return anything, but also, doesn't run the program).

It uses swing, and when I run it:

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)

It says that their is no such method of .requestFocus.

This was auto-generated with Netbeans, and it works fine in Netbeans. However, it doesn't in the cmd/powershell.

Thanks,

Justin W.


Solution

  • I believe you are using the java 7 in netbeans and you are using an older version of java from the command line. setAutoRequestFocus is new to java 7.