Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Layout Problem

Hi eveybody......
This is neer.........first of all i wanna say thanx to all u guys......
u all are really very helpful......and i am getting a great help in learning java with the help of u guys........thanx once again......
kk now i am trying Layout Program and it shows the following errors.......

my code is

import java.awt.*;
import java.applet.Applet;
public class Flow extends Applet
{
public Flow()
{
setLayout(new FlowLayout());
add(new Button("java"));
add(new Button("sql"));
add(new Button("C++"));
}
}

and command prompt shows the following error

D:\j2sdk1.4.2_08\bin>java Flow
Exception in thread "main" java.lang.NoSuchMethodError: main

D:\j2sdk1.4.2_08\bin>set CLASSPATH=D:\j2sdk1.4.2_08\bin

D:\j2sdk1.4.2_08\bin>java Flow
Exception in thread "main" java.lang.NoSuchMethodError: main

plz help me in fixing the problem
Thanx in Advance
Neer
[1017 byte] By [neer] at [2007-11-11 7:06:13]
# 1 Re: Layout Problem
>NoSuchMethodError: main

Says it all!

The java program looks in your class file for a method main and calls it.
Your program doesn't have one, so it gives the error message.

The main() method must have a specific signature. Look that up by using search. ALL starting PROGRAMS (not applets) have a main() method.
Norm at 2007-11-11 22:39:18 >
# 2 Re: Layout Problem
You have written a java program that is applet and not application. So to run applets, wtite an htm file or add these lines to your code after import as:

/*<applet code="Flow" height=200 width=200> </applet> */

and then run your applet by :

appletviewer Flow.java instead of java Flow
sandhyaharsh at 2007-11-11 22:40:23 >