Hi.Could some one help. i used the JCreator applet templet to code the following applet.
import java.awt.*;
import java.applet.*;
import javax.swing.*;
/*applet code="LabelDemo"width=300 height200>
</applet>
*/
public class LabelDemo extends JApplet {
public void init() {
//public void start(){
Label one=new Label("one");
Label two=new Label("two");
Label three=new Label("three");
//add labels to applet window
add(one);
add(two);
add(three);
}
}
But when i try to run it i receive the error:
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
I am a begginer in Java.I have tried to check previous forums but i seem not to get the answer.
Thanks in advance
Main Method Not Found
Started by
pp100
, Aug 03 2012 02:26 PM
5 replies to this topic
#1
Posted 03 August 2012 - 02:26 PM
#2
Posted 04 August 2012 - 02:50 PM
pp100, on 03 August 2012 - 02:26 PM, said:
Hi.Could some one help. i used the JCreator applet templet to code the following applet.
But when i try to run it i receive the error:
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
I am a begginer in Java.I have tried to check previous forums but i seem not to get the answer.
Thanks in advance
But when i try to run it i receive the error:
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
I am a begginer in Java.I have tried to check previous forums but i seem not to get the answer.
Thanks in advance
When you run a program you must have a main method:
public static void main(String[] args)
eg:
public class ProgramName
{
public static void main(String[] args)
{
int value;
...
#3
Posted 07 August 2012 - 10:55 AM
pp100, on 03 August 2012 - 02:26 PM, said:
Hi.Could some one help. i used the JCreator applet templet to code the following applet.
import java.awt.*;
import java.applet.*;
import javax.swing.*;
/*applet code="LabelDemo"width=300 height200>
</applet>
*/
public class LabelDemo extends JApplet {
public void init() {
//public void start(){
Label one=new Label("one");
Label two=new Label("two");
Label three=new Label("three");
//add labels to applet window
add(one);
add(two);
add(three);
}
}
But when i try to run it i receive the error:
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
I am a begginer in Java.I have tried to check previous forums but i seem not to get the answer.
Thanks in advance
import java.awt.*;
import java.applet.*;
import javax.swing.*;
/*applet code="LabelDemo"width=300 height200>
</applet>
*/
public class LabelDemo extends JApplet {
public void init() {
//public void start(){
Label one=new Label("one");
Label two=new Label("two");
Label three=new Label("three");
//add labels to applet window
add(one);
add(two);
add(three);
}
}
But when i try to run it i receive the error:
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
I am a begginer in Java.I have tried to check previous forums but i seem not to get the answer.
Thanks in advance
#4
Posted 07 August 2012 - 10:58 AM
nyccanuck, on 04 August 2012 - 02:50 PM, said:
When you run a program you must have a main method:
eg:
public static void main(String[] args)
eg:
public class ProgramName
{
public static void main(String[] args)
{
int value;
...thanks but this is an applet and with applets what i have read) program execution begins on init().is this not so?
#5
Posted 07 August 2012 - 01:53 PM
pp100, on 07 August 2012 - 10:58 AM, said:
thanks but this is an applet and with applets what i have read) program execution begins on init().is this not so?
To be honest, I am not sure as I do not deal with applets. But what I can tell you is that your error message when you try to run your program says:
Quote
Error: Main method not found in class LabelDemo, please define the main method as:
public static void main(String[] args)
public static void main(String[] args)
So looks to me like you are required to have a main method, or at the very least your program is looking for one. Maybe someone else can comment on the applets.
#6
Posted 11 August 2012 - 03:02 PM
The template includes a HTML file which you need to host your applet.
Make sure the workspace has one or otherwise create a new project.
In the project settings window, select the HTML file as main/run.
Make sure the workspace has one or otherwise create a new project.
In the project settings window, select the HTML file as main/run.










