LIS 523/5 - Java
Java is an object-oriented programming language
with a family resemblance to to C++,
but somewhat simplified.
It was originally developed for handheld devices
(under the name OAK) by Sun Microsystems
and received its present name in 1995
when it was extended for use on the Web.
Java source code (*.java) files
are semi-compiled into a (*.class)
which can then be executed by a Java interpreter
or compiled for a particular machine
by a just-in-time (JIT) compiler.
Java interpreters or JIT compilers
and runtime environments
(Java Virtual Machines)
exist for most operating systems,
including UNIX, Macintosh OS, and Windows.
Small Java applications
are called Java applets
and can be downloaded from a Web server
and run by a Java-compatible Web browser,
such as Netscape Navigator
or appropriate installations of Microsoft Internet Explorer.
Unlike full applications,
applets are not designed to be executed directly
from the operating system.
Java applet usage is small
(about 1¼% of Web sites in April, 2007,
according to Security Space).
In an agreement with Sun, Microsoft
is phasing out the Microsoft Java Virtual Machine (MSJVM),
which is not included in more recent versions of Windows
and support for which is to end at the end of 2007.
Those wishing to run Java applets
can still download a free plug-in from Sun.
What Are Java Applets Used For?
Here are some of the more common applications
for which Java applets have been employed:
- Advertisements and product demonstrations.
- Animated logos and other "eye candy".
- Instructional materials, especially in science.
- Client-side search engines.
- Some kinds of utilities,
such as FTP clients.
There are many ready-made Java applets
available on the Web.
How to Incorporate a Java Applet in a Web Page
If you change the HTML code for the applet at all
(usually to modify one of the applet's parameters),
refreshing or reloading the page in the browser is not
to reset the applet;
instead, you will need to request the page again explicitly by URL
or as a local file.
- First, get the applet files,
either by downloading
or by creating your own
(for which, you will need a Java compiler);
for downloaded files,
read any documentation.
- Put the files in a directory
that can be accessed on the Web.
- Edit an HTML file
to include the appropriate applet tag;
Please enable your Java
- Try to run the applet using a Web browser.
This will not work
unless you have Java enabled;
for example, in Netscape,
you should select "Edit|Preferences|Advanced"
and make sure that "Enable Java"
- If you get the HTML page
with a blank box where the applet should be,
you can try viewing the Java Console:
select "Communicator|Tools|Java console"
(this does nothing if Java is not enabled);
in Internet Explorer,
select "View|Internet Options|Advanced"
then click on "Java Console enabled",
and finally, select "View|Java console".
This will tell you what errors occurred,
though not how to fix them.
As an example,
if you have Java enabled
and it is working correctly with your browser,
you should see below
a message that fades in and out again a black background.
Some Restrictions on Applets
For client security reasons,
there are a number of things that applets
are not allowed to do:
- use Java code other than their own
and what the viewer's Java API provides;
- read or write files on the client
(though applets in any applet viewer
can read files specified with full URLs
and can forward data to an application on the server);
- make network connections
except to the server that they came from;
- start any program on the client;
- read certain system properties;
- create windows that look the same
as those of a regular application.
Java applets tend to create problems for visitors:
they tend to be slow,
as well as inconsistent in speed;
they may not work in some browsers
or when delivered by some servers,
or will suddenly cease working for no apparent reason;
and they can cause the browser to crash.
Some applets work only with more recent versions
of the Java Virtual Machine.
Installing or updating the Java Virtual Machine
requires administrator privileges,
which users may not have
(for example, users of the FIMS labs).
Sun also offers servlet technology.
A servlet is almost like an applet,
except that it runs on the server.
Unlike proprietary server extension mechanisms
(such as Microsoft FrontPage extensions),
servlets are designed to be independent of the server platform.
JavaServer Pages (JSP) technology
is an extension of the servlet technology
along the same lines as Microsoft's
Active Server Pages (ASP).
For More Information
For more links,
see Yahoo!'s Java page
Last updated April 20, 2007.
This page maintained by
Prof. Tim Craven
E-mail (text/plain only): firstname.lastname@example.org
Faculty of Information and
University of Western
Canada, N6A 5B7