Java- applet

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.

  1. Local Applet
  2. 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. 

Local computer

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.

Loading a Remote applet

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 executionIt need main() method for execution
It cannot run independently and require API’s.It just need JRE
Java Applet must extend “java.applet” . Applet classJava Application do not need to extend any class unless require.
Java Applets cannot do soJava Applications can execute codes from the local system

Recommended posts:

How are java objects stored in memory?.

Reference:

programming with java Balagurusamy.

www.edureka.com

Leave a Reply

Your email address will not be published. Required fields are marked *