problem with main
import javax.swing.*;
import java.awt.*;
public class YellowFace extends JApplet
{
public static final int FACE_DIAMETER = 200;
public static final int X_FACE = 100;
public static final int Y_FACE = 50;
public static final int EYE_WIDTH = 10;
public static final int EYE_HEIGHT = 20;
public static final int X_RIGHT_EYE = 155;
public static final int Y_RIGHT_EYE = 95;
public static final int X_LEFT_EYE = 230;
public static final int Y_LEFT_EYE = Y_RIGHT_EYE;
public static final int NOSE_DIAMETER = 10;
public static final int X_NOSE = 195;//Center of nose will be at 200
public static final int Y_NOSE = 135;
public static final int MOUTH_WIDTH = 100;
public static final int MOUTH_HEIGHT = 50;
public static final int X_MOUTH = 150;
public static final int Y_MOUTH = 175;
public static final int MOUTH_START_ANGLE = 180;
public static final int MOUTH_DEGREES_SHOWN = 180;
public void paint(Graphics canvas)
{
//Draw face circle:
canvas.setColor(Color.YELLOW);
canvas.fillOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);
canvas.setColor(Color.BLACK);
canvas.drawOval(X_FACE, Y_FACE, FACE_DIAMETER, FACE_DIAMETER);
//Draw eyes:
canvas.setColor(Color.BLUE);
canvas.fillOval(X_RIGHT_EYE, Y_RIGHT_EYE, EYE_WIDTH, EYE_HEIGHT);
canvas.fillOval(X_LEFT_EYE, Y_LEFT_EYE, EYE_WIDTH, EYE_HEIGHT);
//Draw nose:
canvas.setColor(Color.BLACK);
canvas.fillOval(X_NOSE, Y_NOSE, NOSE_DIAMETER, NOSE_DIAMETER);
//Draw mouth:
canvas.setColor(Color.RED);
canvas.drawArc(X_MOUTH, Y_MOUTH, MOUTH_WIDTH, MOUTH_HEIGHT,
MOUTH_START_ANGLE, MOUTH_DEGREES_SHOWN);
}
}
i have copied this code from a book and i have a problem. when i compile it appears this message:
java.lang.NoSuchMethodError: main
Exception in thread "main" .
Should i put a main in another file? And how can i call this class?Thx a lot
View Answers
March 3, 2010 at 10:42 AM
Hi Friend,
This is an applet code and applet doesn't have main method therefore compile it and run it with html file.
applet.html:
<html>
<body>
<h1>Java Applet Demo</h1>
<applet code=YellowFace.class width=500 height=400>
</applet>
</body>
</html>
Thanks
Related Tutorials/Questions & Answers:
problem with main - Java Beginners a
problem. when i compile it appears this message:
java.lang.NoSuchMethodError:
main
Exception in thread "
main" .
Should i put a
main in another file? And how can...
problem with main
import javax.swing.*;
import java.awt.
ProblemProblem import java.io.*;
import java.net.*;
public class EchoClient
{
public static void
main(String[] args) throws IOException
{
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader
Advertisements
ProblemProblem import java.io.*;
import java.net.*;
public class EchoClient
{
public static void
main(String[] args) throws IOException
{
Socket echoSocket = null;
PrintWriter out = null;
BufferedReader
problemproblem import java.io.*;
class ranveer
{
public static void
main(String args[])throws IOException
{
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
int m=Integer.parseInt(in.readLine());
int n
main methodmain method Why is the java
main method static
main methodmain method What is the argument type of a program's
main() method
main functionmain function Give me the description of public static void
main(Strings args
main() methodmain() method Can we define two
main() methods having same parameter but with different return type in a program
main methodmain method hello,
Can I make multiple
main methods in the same...; hello
No we can not make multiple
main with in the same class program fails to compile. Compiler gives error that the
main method is already defined
MAin errorMAin error Error while running hello program in another dir rather... but @ d tym of runnin error in
main class is generated
Exception in thread "
main".java.lang.NoClassFoundDefLoader. : Hello
caused
main methodmain method psvm(String args[])
what does this arguement in paranthesis denote?
Hi Friend,
public-It indicates that the
main() method can be called by any object.
static-It indicates that the
main() method
PROBLEM IDENTIFICATIONPROBLEM IDENTIFICATION class MOrders
{
int nooforders; // Data members of the class
public int getorder()
{
nooforders = 500;
}
public void...: "+
nooforders);
}
public static void
main(String args[])
{
MOrders obj = new MOrders
Problem in ArrayProblem in Array Hi, Can you help me with this
problem?
Run a program that check if the input string contains equal number of A's and B's.
Hoping... static void
main(String[] args)
{
String st="ABRA KA DABRA
Exception in thread "main" java.lang.ClassCastExceptionException in thread "
main" java.lang.ClassCastException I am trying...){e.printStackTrace();}
}
}
public static void
main(String[] argv) {
try {
Class driver..._jdbc.java:37:error:package org.postgresql doesnot exist
can anyone solve this
problem Exception in thread "main" java.lang.ClassCastExceptionException in thread "
main" java.lang.ClassCastException I am trying...){e.printStackTrace();} } }
public static void
main(String[] argv) { try { Class driver...:error:package org.postgresql doesnot exist
can anyone solve this
problem its
why not float main?why not float
main? why should the
main be int or void?why cant it be float or char?
why int
main()?why not float
main()?or char
main why not float main?why not float
main? why should the
main be int or void?why cant it be float or char?
why int
main()?why not float
main()?or char
main PROBLEM IN EXECUTIONPROBLEM IN EXECUTION class R {
private int x;
private int y...);
}
}
class J {
public static void
main(String args[]) {
R c1,c2;
c1...);
}
}
class J {
public static void
main(String args[]) {
R c1,c2;
c1
problem in onlinetest...problem in onlinetest... hi,
my code getting the
problem is ,when user leave a question then the server puts error...
pls help me
JSON main questionJSON
main question What is the
main purpose of JSON ,in which cases can i use
JSON main questionJSON
main question What is the
main purpose of JSON ,in which cases can i use
ModuleNotFoundError: No module named 'main'ModuleNotFoundError: No module named '
main' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
main'
How to remove the ModuleNotFoundError: No module named '
main' error
ModuleNotFoundError: No module named 'main'ModuleNotFoundError: No module named '
main' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
main'
How to remove the ModuleNotFoundError: No module named '
main' error
java sleep in main methodjava sleep in
main method Hi,
How to write Java program for sleeping in the
main method?
I want Java program to have sleep in
main method. Try to share me the code examples.
Thanks
java sleep in main methodjava sleep in
main method Hi,
How to write Java program for sleeping in the
main method?
I want Java program to have sleep in
main method. Try to share me the code examples.
Thanks
Main job of cpuMain job of cpu What is the
Main Job of CPU?
The CPU perform two
main task ..
1. It carry out program instructions and also
2. Process the data and information
public static void mainpublic static void main what is mean public static void
main?
public-It indicates that the
main() method can be called by any object.
static-It indicates that the
main() method is a class method.
void- It indicates
What is the arguement of main method?What is the arguement of
main method? hi,
What is the arguement of
main method?
thanks,
Hi,
For
main() method accepts only an array of String object as arguement. For moe details on http://www.roseindia.net/java
Can a main method be overloaded? Can a
main method be overloaded? Hi,
Can a
main method be overloaded?
thanks,
Hi,
Yes, In Java program we could having multiple number of
main() methods with different Signature and implementation in the class
main func - Java Beginnersmain func why do we pass array of strings in
main function of java? Hi Friend,
It is used to signify that the user may opt to enter parameters to the java program at command line.
Thanks
main() syntax - Java Beginnersmain() syntax Hi,
I would like to know the complete structure of the
main() in jdk1.5
with sample program.
Regards,
UsmanAli Shaik,
...]
[import statements]
[class declaration]
[
main() method]
For Example:
package
problem in validationproblem in validation sir/madam,
i m using struts-1.3.10. i m getting a
problem my properties file is not found....
while i hav configuired it in struts-config.xml file,
likeADS_TO_REPLACE_1
thanks n regards
himanshu
javascript problemjavascript problem hi guys
My
problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter
please help me this
problem for a problem in coading - Java Beginnersfor a
problem in coading what is the problm in following coading....having run time error-"exception in thread "
main" java.lang.noclassdefFounderror... ();
f.setSize( 500,500);
f.setVisible(true);
}
public static void
main Main features of JSP technologyMain features of JSP technology
Main features of JSP technology ?
A language for developing JSP pages, which are text-based documents that describe how to process a request and construct a response.
Constructs
Is main method compulsory in Java?Is
main method compulsory in Java? Hi,
Can we have a executable class in Java without a
main method? I am going to write simple Java program and there is
main method.
Is
main method compulsory in Java?
Thanks
Hi
Main function.. - Java BeginnersMain function.. Hi Friend..
public static void
main(String args[])
What does it mean...public - static - void -
main -(String args[])
Can u plz... return the value when it exits
main(): This is the entry point for the application
jdbc problem jdbc
problem hi my name is mohit...i am making a project in java...);
}*/
}
/**
* @param args the command line arguments
*/
public static void
main(String...
main(String[] args) {
try
{
Connection con = null;
Statement stmt
problem on stringsproblem on strings in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this
with out using StringBuffer concept.
Thanks in advanace
Problem with loginbean.jspProblem with loginbean.jsp http://www.roseindia.net/jsp/loginbean.shtml
-
I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this?
Also in this example how
compilation problemcompilation problem struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation
problem that package open symphony doesnot... havenot set the build path.if this is the
problem then tell me how to set
compilation problemcompilation problem struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation
problem that package open symphony doesnot... havenot set the build path.if this is the
problem then tell me how to set
Problem with cookiesProblem with cookies Hello All,
i need jsp code for RememberMe module of login.
i am facing
problem with cookies. so please if any one could guide me please help and provide mme the exact code.
Please visit
problem with packageproblem with package Dear sir,
i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The
problem is i want to use that .class file in some other
Oracle9i ProblemOracle9i Problem Hi
I have a
problem in Oracle9i .I have... the table what i created .But after closing the SQL+ ,the
problem started.When i... .....;.it is saying no rows are selected.Why the
problem arised in not getting the data that i
problem with session.invalidate()problem with session.invalidate() i stuck by a line with "session.invalidate()", after user logout also by pressing the back button of the browser user is still able to navigate to his home page and able to view the session
JScrollBar Problem...JScrollBar
Problem... Hello Sir/mam,
Can i know how to use JScrollBar to JFrame without adding any JPanel to it..
i want to add JScrollBar Directly to JFrame...
Please Provide me Simple Example so i can understand