Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jul 11th, 2005, 10:46 AM   #1
1stMan
Newbie
 
Join Date: Jul 2005
Posts: 1
Rep Power: 0 1stMan is on a distinguished road
Trying to run a java program

Hi,

I am trying to run a program in Java but it is not working. It compiles fine, but when i run it, it gives the error message:

"Exception in thread "main" java.lang.NoSuchMethodError: main"

Does anybody know what the problem is?

Thanks in advance.



Below is the code:

/*Mandel.java - Java Mandelbrot by MN Karthik. 
Any questions, comments, suggestions? You can contact me at mnkarthik@yahoo.com.
*/
import java.awt.Graphics;
import java.awt.Color;

public class Mandel extends java.applet.Applet {

    public void paint(Graphics g) {
  int sx=320;           //Screenwidth
  int sy=240;           //Screenheight
  double xmin=-2;       //smallest real value (x-axis)
  double xmax=1.25;     //largest real value (x-axis)
  double ymin=-1.25;    //smallest imaginary value (y-axis)
  double ymax=1.25;     //largest imaginary value (y-axis)
  double maxiter=512;       //Max number of iterations

  double old_x;         //temporary variable to store x-value
  double fx,fy;        
  int m;                //variable to store number of iterations

  double dx=(xmax-xmin)/sx; //how much to add for each x-pixel?
  double dy=(ymax-ymin)/sy; //how much to add for each y-pixel?

  int px;               //Variable storing current x-pixel
  int py=0;             //Variable storing current y-pixel
  double x;             //Variable storing current x-value
  double y=ymin;        //Variable storing current y-value

 g.setColor(Color.black);
 g.drawString("Rendering Mandelbrot..... please wait", 72, 220);
  while (py<sy) {
	 px=0;
	 x=xmin;
	 py++;
	 while (px<sx) {
		px++;

		fx=0;           
		fy=0;
		m=0;            
		do {
		  old_x=fx;      
		  fx=fx*fx-fy*fy+x;   
		  fy=2*old_x*fy+y;  
		  m++;                
		} while (((fx*fx+fy*fy)<4) && (m<maxiter)); 
	    if (m%2==0) g.setColor(Color.white);
	    if (m%3==0) g.setColor(Color.green);
	    if (m%4==0) g.setColor(Color.blue);
	    if (m%5==0) g.setColor(Color.red);
	    if (m%6==0) g.setColor(Color.yellow);
	    if (m%7==0) g.setColor(Color.cyan);
	    if (m%8==0) g.setColor(Color.magenta);
	    if (m%9==0) g.setColor(Color.orange);
	    if (m%10==0) g.setColor(Color.pink);
	    if (m%11==0) g.setColor(Color.gray);
	    if (m%12==0) g.setColor(Color.red);
	    if (m%13==0) g.setColor(Color.black);	g.drawLine(px-3,py-3,px+10,py+10);	 //the +10 adds a nice effect while rendering :)
	 x+=dx;
	 }
  y+=dy;
  }
  g.setColor(Color.black);
  g.drawString("Java Mandelbrot By MN Karthik", 3, 10);
    }
  public String getAppletInfo() {
    return "Java Mandelbrot by MN Karthik (mnkarthik@yahoo.com)";
  }
}
1stMan is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:59 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC