官术网_书友最值得收藏!

1.5 Java Applet

A Java applet is an applet delivered to users in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, a stand-alone tool for testing applets. Java applets were introduced in the first version of the Java language in 1995, and are written in programming languages that compile to Java bytecode, usually in Java, but also in other languages such as Jython, JRuby, or Eiffel (via SmartEiffel).

Java applets run at speeds comparable to, but generally slower than, other compiled languages such as C++, but until approximately 2011 many times faster than JavaScript. In addition they can use 3D hardware acceleration that is available from Java. This makes applets well suited for non trivial, computation intensive visualizations. When browsers have gained support for native hardware accelerated graphics in the form of Canvas and WebGL, as well as Just In Time compiled JavaScript, the speed difference has become less noticeable.

Applet或Java小應用程序是一種在Web環境下,運行于客戶端的Java程序組件。它也是20世紀90年代中期,Java在誕生后得以一炮走紅的功臣之一。通常,每個Applet的功能都比較單一(如僅用于顯示一個舞動的Logo),因此它被稱做“小應用程序”。

Since Java's bytecode is cross-platform or platform independent, Java applets can be executed by browsers for many platforms, including Microsoft Windows, Unix, Mac OS and Linux. It is also trivial to run a Java applet as an application with very little extra code. This has the advantage of running a Java applet in offline mode without the need for any Internet browser software and also directly from the integrated development environment (IDE).

The applet can be displayed on the web page by making use of the deprecated applet HTML element, or the recommended object element. Embed element can be used with Mozilla family browsers (embed is no longer deprecated in since HTML 5). This specifies the applet's source and location. Object and embed tags can also download and install Java virtual machine (if required) or at least lead to the plug-in page. Applet and object tags also support loading of the serialized applets that start in some particular (rather than initial) state. Tags also specify the message that shows up in place of the applet if the browser cannot run it due any reason.

Applet必須運行于某個特定的“容器”,這個容器可以是瀏覽器本身,也可以是通過各種插件,或者包括支持Applet的移動設備在內的其他各種程序來運行。

However, despite object being officially a recommended tag, as of 2010, the support of the object tag was not yet consistent among browsers and Sun kept recommending the older applet tag for deploying in multibrowser environments, as it remained the only tag consistently supported by the most popular browsers. To support multiple browsers, the object tag currently requires JavaScript (that recognizes the browser and adjusts the tag), usage of additional browser-specific tags or delivering adapted output from the server side. Deprecating applet tag has been criticized. Oracle now provides a maintained JavaScript code to launch applets with cross platform workarounds

與一般的Java應用程序不同,Applet不是通過main方法來運行的(參見Java的Hello World程序和Java Applet的Hello World程序)。在運行時Applet通常會與用戶進行互動,顯示動態的畫面,并且會遵循嚴格的安全檢查,阻止潛在的不安全因素(如根據安全策略,限制Applet對客戶端文件系統的訪問)。

主站蜘蛛池模板: 竹山县| 沂南县| 平安县| 同心县| 林甸县| 剑川县| 苏州市| 宝清县| 崇信县| 铜梁县| 元江| 平顶山市| 奉贤区| 共和县| 柳河县| 缙云县| 尉犁县| 湖南省| 温宿县| 盖州市| 大新县| 西藏| 东城区| 德庆县| 洪雅县| 资兴市| 汾西县| 瑞昌市| 神农架林区| 安义县| 阳春市| 桂阳县| 太原市| 崇明县| 巴林右旗| 海阳市| 肥西县| 克什克腾旗| 定远县| 葫芦岛市| 屯门区|