14.07.2013 Views

Contents - Cultural View

Contents - Cultural View

Contents - Cultural View

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java applet 35<br />

}<br />

}<br />

g.drawString("Hello, world!", 20,10);<br />

More simple applets are available at Wikiversity [23] .<br />

For compilation, this code is saved on a plain-ASCII file with the same name as the class and .java extension, i.e.<br />

HelloWorld.java. The resulting HelloWorld.class applet should be installed on the web server and is<br />

invoked within an HTML page by using an or an tag. For example:<br />

<br />

<br />

<br />

HelloWorld_example.html<br />

<br />

<br />

A Java applet example<br />

Here it is: <br />

This is where HelloWorld.class runs.<br />

<br />

<br />

Displaying the HelloWorld_example.html page from a Web server, the result should look as this:<br />

A Java applet example<br />

Here it is: Hello, world!<br />

To minimize download time, applets are usually delivered in a form of compressed zip archive (having jar<br />

extension). If all needed classes (only one in our case) are placed in compressed archive example.jar, the embedding<br />

code would look differently:<br />

Here it is: <br />

This is where HelloWorld.class runs.<br />

Applet inclusion is described in detail in Sun's official page about the APPLET tag. [24]<br />

Advantages<br />

A Java applet can have any or all of the following advantages:<br />

• It is simple to make it work on Linux, Microsoft Windows and Mac OS X i.e. to make it cross platform. Applets<br />

are supported by most web browsers.<br />

• The same applet can work on "all" installed versions of Java at the same time, rather than just the latest plug-in<br />

version only. However, if an applet requires a later version of the Java Runtime Environment (JRE) the client will<br />

be forced to wait during the large download.<br />

• Most web browsers cache applets, so will be quick to load when returning to a web page. Applets also improve<br />

with use: after a first applet is run, the JVM is already running and starts quickly (the JVM will need to restart<br />

each time the browser starts afresh).<br />

• It can move the work from the server to the client, making a web solution more scalable with the number of<br />

users/clients.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!