Sunday, 15 April 2012

java - Applet doesn't run and asks for main method -



java - Applet doesn't run and asks for main method -

i novice in java programming.this applet code simpleapplet.java:

import java.awt.*; import java.applet.*; /* <applet code="simpleapplet" width=200 height=60> </applet> */ public class simpleapplet extends applet { public void paint(graphics g) { g.drawstring("a simple applet",20,20); } }

i first compiled in command prompt javac simpleapplet.java , used java simpleapplet. throws error main class not found in class simpleapplet,please define main method. wrong here ?

javac simpleapplet.java

and used

java simpleapplet

do instead:

javac simpleapplet.java appletviewer simpleapplet.java

the trick here applet viewer read source, , utilize applet element defined in comment create 'applet html' run it.

java applet

No comments:

Post a Comment