In Java, programs that can run independently are called Java applications ). The Java language also has an applet program. An applet (also known as a Java applet) is a program that runs in a variety of webpage files and is used to enhance the human-computer interaction, animation display, sound playback, and other functions of a webpage.
The main differences between Java Applet and Java application are as follows:
(1) The running mode is different. Java Applet cannot run independently. It must be attached to a webpage written in HTML and embedded in it, and controlled and executed through a Java-compatible browser. Java application is a complete program that can run independently. As long as there is a virtual machine that supports Java, it can run independently without the support of other files.
(2) Different running tools. The interpreter running the Java applet is not an independent software, but embedded in the browser as part of the browser software. After the Java application program is compiled, it can be interpreted and executed with a common Java interpreter. Java Applet can only be executed through a Web browser or applet observer.
(3) The program structure is different. Each Java application must contain one and only one main method. When executing a program, you must first find the main method and run it as the entry point. The class that contains the main method is often called the main class, that is, the Java application program contains a main class. The applet does not have the main class containing the main method, which is exactly why the applet cannot run independently. Although the applet does not have a main class containing the main method, the applet must have a class derived from Java. Applet. Applet, which is provided by the java system.
(4) Java Applet can directly use the graphical user interface provided by the browser or appletviewer, while Java application must write additional special code to build its own graphical interface.
(5) Restricted different Java application programs can be designed to perform various operations, including reading/writing file operations, however, Java Applet neither reads nor writes the disk files of the site. However, due to the introduction of Applet, web pages have dynamic multimedia effects and interactive performance, this enables a Web page written in HTML language named Hypertext and plain text to have the hypertext function, which not only displays text information, in addition, it can have a variety of image effects and dynamic graphics effects to make the page appear vivid and beautiful. In addition, the applet adds buttons and other functions to the web page, thus increasing interaction.
The main differences between Java Applet and Java application are as follows: Java application is generally run on a local machine, while Java applet is generally placed on a server, it is downloaded to the local machine according to the local machine request, and then runs on the local machine.