Java Applets and the Internet

The idea here is simple: Users will download Java bytecodes from the Internet and run them on their own machines. Java programs that work on web pages are called applets.To use an applet, you only need a Java-enabled web browser, which will execute the bytecodes for you. You need not install any software. Because Sun licenses the Java source code and insists that there be no changes in the language and standard library, a Java applet should run on any browser that is advertised as Java-enabled. You get the latest version of the program whenever you visit the web page containing the applet.Most important, thanks to the security of the virtual machine, you need never worry about attacks from hostile code.

1.3 Java Applet与Internet

这里的想法很简单:用户从Internet下载Java字节码,并在自己的机器上运行。在网页中运行Java程序称为applet。为了使用applet,需要启用Java的Web浏览器执行字节码。由于Sun公司负责发放Java源代码的许可证,并坚持不允许对语言和基本类库的结构做出任何修改,因此,Java的applet应该可以运行在任何启用Java浏览器上,并且无论何时访问包含applet的网页,都会得到程序的最终版本。最重要的是,要感谢虚拟机的安全机制,它让我们不必再担心来自恶意代码的袭击。

When the user downloads an applet, it works much like embedding an image in a web page. The applet becomes a part of the page, and the text flows around the space used for the applet. The point is, the image is alive. It reacts to user commands, changes its appearance, and sends data between the computer presenting the applet and the computer
serving it.

用户下载一个applet就如同在网页中嵌入一幅图片。applet成为了页面的一部分。文本环绕着applet所占据的空间周围。关键一点是图片是活动的。它可以对用户命令做出响应,改变外观,在运行它的计算机与提供它的计算机之间传递数据。

Figure 1–1 shows a good example of a dynamic web page that carries out sophisticated calculations. The Jmol applet displays molecular structures. By using the mouse, you can rotate and zoom each molecule to better understand its structure. This kind of direct manipulation is not achievable with static web pages, but applets make it possible. (You can find this applet at http://jmol.sourceforge.net.)

【Core Java】【Volume I ~Fundamentals】【Chapter 1】【1.3】【Java Applets and the Internet】_字节码 

图1-1展示了一个很好的动态网页的示例。Jmol applet显示了分子结构,这将需要相当复杂的计算。在这个网页中,可以利用鼠标进行旋转,调整焦距等操作,以便更加细致地理解分子结构。用静态网页将无法实现这种直接的操作,而applet却可以达到此目的。(可以在http://jmol.sourceforge.net上找到这个applet)

When applets first appeared, they created a huge amount of excitement. Many people believe that the lure of applets was responsible for the astonishing popularity of Java.However, the initial excitement soon turned into frustration. Various versions of Netscape and Internet Explorer ran different versions of Java, some of which were seriously outdated. This sorry situation made it increasingly difficult to develop applets
that took advantage of the most current Java version. Today, most web pages simply use JavaScript or Flash when dynamic effects are desired in the browser. Java, on the other hand, has become the most popular language for developing the server-side applications that produce web pages and carry out the backend logic.

当applet首次出现时,人们欣喜若狂。许多人相信applet的魅力将会导致Java迅速地流行起来。然而,出气的兴奋很快就淡化了。不同版本的Netscape与Internet Explorer运行不同版本的Java,其中有些早已过时。这种糟糕的情况导致更加难于利用Java的最新版本开发applet。今天,当需要在浏览器中显示动态效果时,大多数网页都直接使用JavaScript或Flash。另外,已经成为用来开发服务器端应用程序的最流行的语言,使用这些服务器端应用程序可以产生网页、运行后端逻辑。