In java, an applet is a small program embedded within the HTML web page. An applet can transfer over the Internet from one computer to another computer. A Java applet, executed by using a browser that supports java or using Applet Viewer. An applet is embedded in HTML page using <applet> or <object> tags and hosted on a web server. It can perform many tasks Such as, create animation, play games, play sound, display graphics, etc.
The applets code is downloaded along with the requested web page whenever user accesses an HTML page. Finally executed there under the control of JVM(Java Virtual Machine).
There are two ways to embed applets into web pages.
- Local Applet
- Remote Applet
Local Applet
In this way, an applet developed locally and stored in a local system called a local applet. Therefore we can write an applet our applets and embed them into web pages. When a web page is trying to find a local applet, it doesn’t need internet. So web page can simply search the directories in the local system.
Remote Applet
In which an applet developed by someone else and stored on a remote computer known as a remote applet. Therefore We can download an applet from a remote computer and embed it into a webpage needed an internet connection.
To locate and load a remote applet, we must know the address of the applet on the web. This address is known as URL which is known as Uniform Resource Locator and also must be specified in the applet’s HTML document as the value of the CODEBASE attribute.
EXAMPLE:
CODEBASE = http://www.netserve.com/applet
applets Vs application in java
Applets | Application |
---|---|
don’t need main() method for execution | It need main() method for execution |
It cannot run independently and require API’s. | It just need JRE |
Java Applet must extend “java.applet” . Applet class | Java Application do not need to extend any class unless require. |
Java Applets cannot do so | Java Applications can execute codes from the local system |
Recommended posts:
How are java objects stored in memory?.
Reference:
programming with java Balagurusamy.