Creating an Executable Applet in Java

An executable applet is nothing but the .class file of the applet which is obtained by compiling the source code of the applet. Compiling an applet is exactly the same as compiling an application.

 
import java.applet.*;
import java.awt.*;

public class test extends Applet 
{
   public void paint(Graphics g) 
{
      g.drawString("Hello World",50,20);
   }
}

Create an HTML File and adding it with the Applet
<html>
   <head>
   </head>
   <body>
         <applet code = "test.class" width = "600" height = "400"></applet>
   </body>
</html>


Note : We must name this file as test.html and save it in the same directory as the compiled applet.

Recommended Posts:

Advanced Java
    1. Difference between Local Applet and Remote Applet
    2. Applet Life Cycle in Java
    3. Difference Between Applet and Application
    4. Creating an Executable Applet in Java
    5. Displaying Numerical values in Applet
    6. An Applet Program to Add Two Numbers
    7. Event Handling in Applet
    8. AWT Classes in Java
    9. Draw a line and rectangle in Java Applet
    10. Draw Circles and Ellipses in Java Applet
    11. Draw Arc in Java Applet
    12. Develop an Applet for Drawing a Human Face
    13. Draw a Polygon in Java Applet
    14. Draw Line Graph in Java Applet
    15. Java Applet Program to Draw National Flag
    16. Demonstrate to Draw Bar Charts in Java