Java Applet Example

To run applets we use  appletviewer .

An appletviewer is command line program to invoke an applet program from command line.

Here we will see how to run applet from applet viewer

Example : Write a simple applet program to print “ Hello Students”

Compile  Save & Run:  Save this file with APDemo.java name.

Compile : javac APDemo.java

Run: appletviewer ApDemo.java

Applet Running on applet viewer

Example : Write a simple applet program to print “ Hello Students” and show the how init(), start() ,paint(), stop() and destroy() method executes in a sequence.

Note: In an applet program first init() method executes then start() method. After start(), paint() executes.

Compile  Save & Run:  Save this file with ApDemo1.java name.

Compile : javac APDemo1.java

Run: appletviewer APDemo1.java

Applet running using appletviewer

After running applet we will see following output in console