Hello friends today we learn to make Java First Applet Program or the concept of applet programming. Applet are small program that run in web browser

Java Applets

Hello friends today we learn to make Java First Applet Program or the concept of applet programming. Applet are small program that run in web browser or applet are small program that is intended not to be run on its own ,but rather to be embedded inside another program or application. The applet class must be the super class of any applet that is to be embedded in a web page or viewed by the java applet viewer. Java applet runs on client side within the browser using JRE (java runtime environment) at client machine when it’s embedded in any webpage requested by client. Applet can run under any web browser their execution is dependent on client as they require JRE.
For we have to first include java.applet package and then extend Applet class to make any applet program there are three simple steps
1) Write applet code file and save with .java extension.
2) Make html file to run applet in web browser.
3) Then run the program by using
i) AppletViewer tool.
ii) Run html file in java enabled browser.
Now friends we can start coding but before it please check these conditions
1) Is jdk is installed on your pc.
2) Is path variable for jre is set.
If this condition is fulfilled then we can start coding
EXAMPLE CODE
1.) Java code
import java.applet.*;
import java.awt.*;

public class APP extends Applet
{
public void paint(Graphics g)
{
g.drawOval(50,50,75,75);
}
}
2.) Html code

Now we have to run applet program there are two way
1) Run by using appletviewer tool.
2) Run by just open html file in java enabled browser.

Save code file as APP.java.
Save html file as APP.html
Open cmd and compile the code file using javac command as:= javac APP.java
Now run applet by code := appletviewer APP.html
::::::::::::::::::::::OUTPUT::::::::::::::::::::::::::::

1) output of Applet by using appletviewer tool.

applet

2) output of Applet by run html file in java enabled browser.

applet2

NO COMMENTS