Help with NoSuchMethodError:


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Help with NoSuchMethodError:

  1. #1
    Join Date
    Nov 2004
    Posts
    2

    Help with NoSuchMethodError:

    hey guys new java programmer (hopefully) looking for a little guideness here.

    if just cannot get any program to run off of JCreator to run at all, even the samples that come with the program or source code from the net.

    everytime it loads fine untill in the Dos window (for lack of me knowing a better word) i get "Exception in thread "main" java.lang.NoSuchMethodError: main
    Press any key to continue...

    Heres the code:
    import java.awt.*;
    import java.awt.event.*;

    public class MyFirstFrame extends Frame {

    public MyFirstFrame() {

    MenuBar menuBar = new MenuBar();
    Menu menuFile = new Menu();
    MenuItem menuFileExit = new MenuItem();

    menuFile.setLabel("File");
    menuFileExit.setLabel("Exit");

    // Add action listener.for the menu button
    menuFileExit.addActionListener
    (
    new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MyFirstFrame.this.windowClosed();
    }
    }
    );
    menuFile.add(menuFileExit);
    menuBar.add(menuFile);

    setTitle("MyFirst");
    setMenuBar(menuBar);
    setSize(new Dimension(400, 400));

    // Add window listener.
    this.addWindowListener
    (
    new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    MyFirstFrame.this.windowClosed();
    }
    }
    );
    }

    protected void windowClosed() {

    System.exit(0);
    }
    }

    Could use any help you wise sages could give thx.

  2. #2
    Join Date
    Dec 2004
    Location
    france
    Posts
    35
    Well don't be scared
    that's because any standalone application need a main method in one of class in the code ;
    it will not run without such a mothod
    it goes
    public static void main(string[] lalama){
    // your instructions here
    }
    try again good line

  3. #3
    Join Date
    Dec 2004
    Location
    france
    Posts
    35
    that's should work let me know


    import java.awt.*;
    import java.awt.event.*;

    public class MyFirstFrame extends Frame {

    public MyFirstFrame() {

    MenuBar menuBar = new MenuBar();
    Menu menuFile = new Menu();
    MenuItem menuFileExit = new MenuItem();

    menuFile.setLabel("File");
    menuFileExit.setLabel("Exit");

    // Add action listener.for the menu button
    menuFileExit.addActionListener
    (
    new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    MyFirstFrame.this.windowClosed();
    }
    }
    );
    menuFile.add(menuFileExit);
    menuBar.add(menuFile);

    setTitle("MyFirst");
    setMenuBar(menuBar);
    setSize(new Dimension(400, 400));

    // Add window listener.
    this.addWindowListener
    (
    new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    MyFirstFrame.this.windowClosed();
    }
    }
    );
    }

    protected void windowClosed() {

    System.exit(0);
    }
    /* that's all you needed to add to your nice code lol*/
    public static void main(String[] lalama){

    MyFirstFrame windo=new MyFirstFrame();
    windo.show();

    }
    }

  4. #4
    Join Date
    Nov 2004
    Posts
    2
    thx alot man works great. really appreciate the help. now off to get stumpted some more! thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center