DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2006
    Posts
    4

    Exception in thread main error

    Look at the code .........

    public class DancingRect {
    int locx , locy;
    int width, height;
    Color myColor;


    /** Creates a new instance of DanceRect */
    public DancingRect(int locx ,int locy , int width, int height , Color myColor) {
    this.locx = locx;
    this.locy = locy;
    this.width = width;
    this.height = height;
    this.myColor = myColor;

    }

    public void danceStep()
    {
    }

    public void paint(Graphics g)
    {
    g.setColor(myColor);
    g.fillRect(locx , locy , width, height);
    }

    }


    public class Mondorian extends javax.swing.JApplet
    {
    static final int NUM_RECTS = 9;

    DancingRect r[];

    public void init()
    {
    System.out.println(" <<INIT>>");
    setBackground(Color.black);
    initRectangles();
    }

    public void initRectangles()
    {
    r = new DancingRect[NUM_RECTS];
    r[0] = new DancingRect(0,0,90,90,Color.yellow);
    r[1] = new DancingRect(250,0,40,190,Color.yellow);
    r[2] = new DancingRect(250,55,60,135,Color.yellow);
    r[3] = new DancingRect(80,200,220,90,Color.blue);
    r[4] = new DancingRect(100,10,90,80,Color.blue);
    r[5] = new DancingRect(80,100,110,90,Color.lightGray);
    r[6] = new DancingRect(200,0,45,45,Color.red);
    r[7] = new DancingRect(0,100,70,200,Color.red);
    r[8] = new DancingRect(200,55,60,135,Color.magenta);

    }

    public void start()
    {
    System.out.println(" >>Start <<");
    }

    public void paint(Graphics g)
    {
    for(int i=0;i<NUM_RECTS;i++)
    {
    r[i].paint(g);
    }
    }

    public void stop()
    {
    System.out.println(" <<Stop >>");
    }

    }


    Both the class are placed in separate files and there sorce and class files are in the same directory . The program complies fine but when i try to execute it , it gives " java.lang.NoSuchMethodError: main
    Exception in thread "main" "


    What could be the problem ............

  2. #2
    Join Date
    Mar 2006
    Posts
    35
    how are you trying to execute it? If you're making an applet you can't execute it like a normal java file you have to write an html file to accompany it. Then you view it in your browser or your applet viewer.
    Last edited by blastmaster; 06-28-2006 at 05:45 PM.

  3. #3
    Join Date
    Feb 2006
    Location
    Cologne - Germany
    Posts
    271
    or you use the appletviewer.exe in J2SDK1.4.2_07\bin

Similar Threads

  1. Replies: 4
    Last Post: 12-29-2008, 08:25 AM
  2. Getting a thread to throw an exception
    By jjamesis in forum Java
    Replies: 4
    Last Post: 04-02-2007, 05:37 PM
  3. Replies: 1
    Last Post: 04-25-2006, 08:36 AM
  4. Replies: 3
    Last Post: 07-27-2005, 01:39 AM
  5. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 03:53 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links