Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Creating an Executable Applet

CREATING AN EXECUTABLE APPLET:


Executable applet is nothing but the .class file of applet, which is obtained by compiling the source code of the applet. Compiling the applet is exactly the same as compiling Java application programs.


The compiled output file called “FisrtApplet.class” [as shown in below example] should be placed in the same directory as the source file.




Execution of Java Applets carried out  in two ways.
  1. Using browser.
  2. Using applet viewer.

1. Using browser: Lets take the example of following applet-


APPLET:
import java.applet.Applet;
import java.awt.Graphics;
public class FirstApplet extends Applet {
        public void paint(Graphics g) {
             g.drawString(“Welcome in Java Applet.”,20,20);
          }
}


Now to execute the above applet, type the following code in a text editor,


2. Using applet viewer:
APPLET:
import java.applet.Applet;
import java.awt.Graphics;
public class FirstApplet extends Applet {
        public void paint(Graphics g) {
             g.drawString(“Welcome in Java Applet.”,20,20);
          }
}

Now to execute the above applet, type the following command in a cmd,
  


OUTPUT:



Note: IDE runs Java applets by default in a applet viewer.