A brief introduction to the method of distinguishing applet from application

  • 2020-11-03 22:12:15
  • OfStack

Java is a semi - compiled and semi - interpreted language. Java's user programs fall into two categories: Java Application and Java Applet. These two types of programs have a definite difference in composition structure and execution mechanism:

Application
1.application is mainly the development of desktop applications. application cannot be loaded with Jsp.
Java Application is a complete program that can be run independently.
When the Java Application program is compiled, it can be interpreted and executed using the regular Java interpreter.
4. Each Java Application program must contain 1 and only 1 main method. When the program executes, it first looks for main method and starts running from this entry point. The class that contains the main methods is often referred to as the master class, that is, the Java Application programs each contain a master class.

Applet
1.applet1 is generally used for plug-in development on B/S pages.
The Java Applet program cannot run on its own; it must be embedded in Web pages written in the HTML language and controlled by an ES41en-compatible browser.
Applet must be executed through a web browser or Applet viewer.
4. The Applet program has no main class containing main methods, which is why the Applet program cannot run independently.

Now let's compare the differences between the two to make a better distinction.

(1) Different operation modes.
Java Application is a complete program that can be run independently. The Java Applet program cannot run on its own; it must be embedded in an Web page written in the HTML language and controlled by an ES61en-compatible browser.
(2) Different operation tools.
Once compiled, the Java Application program can be interpreted and executed using the normal Java interpreter, while Java Applet must be executed using a web browser or the Applet viewer.
(3) Different program structure.
Each Java Application program must contain 1 and only 1 main method. When the program executes, it first looks for the main method and starts running from this entry point. The class containing the main method is often referred to as the master class, which means that the Java Application program contains one master class. The Applet program does not have a main class with main methods, which is why the Applet program does not run independently. Although Applet does not have a main class containing the main method, Applet1 must have a class derived from java.applet.Applet, which is provided by the Java system.
(4) Different restrictions.
The Java Application program can be designed to perform a variety of operations, including reading/writing files, but Java Applet can neither read nor write to the site's disk files. However, due to the introduction of Applet, make Web page with dynamic effect of the multimedia and interactive performance, which made by HTML called hypertext, is actually a plain text language into Web page really has the function of hypertext, not only can display text information, but also have a variety of graphics and dynamic graphic effect, thus make the page show lively and beautiful; In addition, Applet adds features such as buttons to the Web page, which increases interactivity.

These are the ways to distinguish applet from application introduced by this site. I hope you can find them helpful.


Related articles: