how to define event to javascript/jquery?

Java Error: please define the main method as....?

  • I keep getting this error: "main method not found in class Applet1, please define the main method as: public static void main(String[] args) " I do not have a main method but this has worked for other people who have the ran the exact same code: import java.awt.*; import java.applet.*; import javax.swing.JOptionPane; /*use a gui to read; make box move includes a pause *an event driven applet */ public class Applet1 extends Applet { Font font; int x, y, w = 20; String s; final boolean T = true, F = false; int len; public void init()//executed by the JVM when the applet is launched { s = JOptionPane.showInputDialog("Type your 15 digit integer please"); len = s.length(); } public void paint(Graphics g)//executed when the applet window is resized { x = 100; y = 100; for(int j = 0; j < len; j++) { int digit = s.charAt(j) - '0'; drawBar(g, digit); x = x + 2*w; } } public void drawBar(Graphics g, int digit) { if(digit == 3) { draw(g, F, T, T, T, T, F, T); } if(digit == 8) { draw(g, T, T, T, T, T, T, T); } } public void draw(Graphics g, boolean ul, boolean top, boolean ur, boolean lr, boolean bottom, boolean ll, boolean mid) { pallet(g, ul); g.drawLine(x, y, x, y-w); pallet(g, top); g.drawLine(x, y-w, x +w, y-w); pallet(g, ur); g.drawLine( x +w, y-w, x+ w, y); pallet(g, lr); g.drawLine( x+ w, y, x+w, y+w); pallet(g, bottom); g.drawLine( x+w, y+w, x, y+w); pallet(g, ll); g.drawLine( x, y+w, x, y); pallet(g, mid); g.drawLine( x, y, x+w, y); } public void pallet(Graphics g, boolean on) { if(on) { g.setColor(Color.red); } else { g.setColor(Color.white); } } } ---- Could it be how I am running it through the command line?

  • Answer:

    I hope you are trying to run this using java command at the dollar prompt. As it is Applet, you have create an html file like: <html> <body> <APPLET code=Applet1 width=200 height=300></APPLET></body></html> If the html file name is abc.html, then open through browser. Or at the DOS prompt run appletviewer abc.html cheers

spontane... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Venkateswarlu is correct. If you run it from the command line, then it does need a main. But if you call it a class method from html, then you do not.

Motorhead

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.