By using Java language we can create user interfaces easily compared with C.We can write applications for different purposes and send them in the Internet.Java applet programs are Java programs encapsulated in HTML.We can create applet programs using different classes provided by the language itself.For example, we can create applets for setting fond colour,fond size and type,background colour etc.
The applet programs can’t directly interact with the operating system.The applets can be sent through networks.So there may may be hidden viruses within the applet.So if it is allowed to contact with the operating system it may cause destruction of the operating system itself.So they are encapsulated within HTML codes.
We can run applet programs by using the HTML tag
<APPLET CODE=”file_name.class” HEIGHT=100 WIDTH=100></APPLET>
First write the Java program and compile it.If the compilation is success a “.class” file is created.Then write the HTML code and include the class file in the applet tag.Set the height and width of the required applet.Save the HTML file in the same name as that of the Java program in the same directory with an extension of “.html or htm”.After that open the HTML file in a web browser like Internet Explorer.
Now we can view the applet.