AGOCG logo
Graphics Multimedia VR Visualization Contents
Training Reports Workshops Briefings Index
 

An Introduction to Java

Introduction

JAVA has been in development, in some form, since the beginning of the decade, but it is over the last eighteen months or so that it has really made the headlines, particularly in conjunction with the World Wide Web (WWW). This paper will look briefly at the history of Java, its current state of development and what the future may hold. This is not a tutorial or introduction to the language, details of such documents can be found in the reference section.

Although Java usually seems to be mentioned in the same breath as the WWW, it is in fact an object-oriented programming language with much wider applications than just the Web. It does, however, have a two main features which make it particularly suitable for creating applications which are delivered over the Web or other distributed environments, namely:

  • Platform independence - Java programs can be run on many platforms without modification. This portability is assured by using a 'virtual machine'. When a Java program is compiled byte-code is created rather than a standard executable file. Effectively, this is machine code for a virtual machine, which is then interpreted by the Java interpreter. The byte-code can be run on any platform which has a suitable interpreter.
  • Security - since Java has always been designed with distributed applications in mind, security has been incorporated right from the start, and if anything this has been seen to be too restrictive.

History

Java originally started life as a language called Oak. The 'Green Project', which developed Oak, was launched by Sun in 1991. Patrick Naughton, one of the project engineers, defined it as an effort to "do fewer things better". Oak was originally designed with PDAs (Personal Digital Assistant) and set-top boxes for interactive television in mind, but after several unsuccessful years, it was realised that many of the requirements of these products and the emerging WWW were similar. Development was shifted to reflect this, and a new web browser WebRunner (later to be renamed HotJava) was developed in 1994, with the alpha version of Java being released in May 1995.

Java and the JDK

Java is a fairly simple language, which will easily be picked up by programmers, particularly those familiar with C++. Although all that is needed to develop Java is a text editor and the JDK (see below), a number of development environments, including visual development environments are available. These include

All the above tools were reviewed in the June 97 issue of JavaWorld, which also contains a full list of Java developer's tools.

Once the code for an application has been written, it is complied into a class file, which contains the byte-code. This code can then be run on any supported platform using the Java interpreter. Applets are created in a similar way, with the source being complied to byte-code. However, the applet is then run by referencing the byte-code from within an HTML file, for example:


<applet code="HelloWorld.class" width=200 height=100>

</applet>

where the width and height parameters are the size of the area the Java applet will run in.

There are many applets available on web sites, providing a wide variety of functions, such as graphing functions, manipulating text and incorporating multimedia. These applets are generally quite small, perform fairly simple tasks and can easily be downloaded as required.

The Java Development Kit contains all the necessary tools for the development of Java applications and applets, including a compiler, interpreter, class libraries, applet viewer and debugger. The current version of the JDK, 1.1.2, is freely available from Sun's web site, for machines running Windows 95, Windows NT, Solaris SPARC and Solaris x86, and a version for the Macintosh is expected later this year (version 1.0 is currently available). Ports to other machines may also be available from other sources. It should be noted that browsers may not yet support applets created using features in the latest JDK.

Security

To provide tight security across distributed applications, all Java applets run in a 'protected space', prohibiting access to the local disk. This is commonly referred to as 'sandboxing'. Although this does provided good security it is also limits the applets' flexibility.

Additional security has been provided with Java 1.1 including the ability to added digital signatures, with the inclusion of the Java Security API (Application Program Interface). Future releases will build on this.

Interactivity on the WWW

Java can provide a secure, cross platform method for applications to be run over the WWW. Additionally, since the Java code is cross platform, the code can be run on the client's machine, so reducing load on the server. However, Java is not the only way to provide interactivity over the Web, and a few of the alternatives are described below.

JavaScript

JavaScript is a scripting language developed by Netscape Communications. Although similar in some ways to Java, it is not a complete programming language, but has designed to be easier to use and accessible to anyone who can write HTML. It is specifically aimed at enhancing web pages. Unlike Java, it is not complied, but interpreted by the browser, like HTML, so JavaScript can be embedded directly into HTML files. It should be noted that a Java-enabled web browser will not necessarily be JavaScript enabled, and vice-versa. Currently only Netscape browsers support JavaScript fully, though Microsoft's Internet Explorer does provide basic support.

Plugins

'Plugins' are programs which run within the web browser, and are called when certain types of data are loaded. For example, a plugin is available enabling Macromedia's Shockwave (a web based multimedia environment derived from Macromedia Director) files to be run. When the web browser loads the Shockwave file, the plugin is automatically called to display it.

ActiveX

ActiveX was developed by Microsoft, and is based their OLE (object linking and embedding) technology. In many ways it represents existing Microsoft technology bundled to work over the Internet. It is not a programming language, but rather a set of rules for how applications should share information. Unlike Java, it is platform dependent, and therefore currently restricted to users running Internet Explorer or Netscape Navigator with the ActiveX plugin, though a beta version is also available for the Macintosh. An ActiveX control is similar to a Java applet, but has a much greater access to the operating system, providing more flexibility but at a cost of decreased security.

The Future

Sun has a number of plans for the future including hardware developments, such as the Java chip, and the continuing development of Java itself. As the interpreted nature of Java currently poses performance problems, faster interpreters and virtual machines will be important in Java's future.

In many ways Java chips represent Java going back to its roots, as they will be low-end chips running Java natively in consumer electronics, such as PDA's, smart phones and network computers. Network Computers are basically diskless workstations that rely on Internet servers to do most of their processing work. Sun released their first JavaStation, which runs JavaOS (Java based operating system), at the end of 1996. In addition to running native Java applications, the NCs will also be able to access the Windows environment and mainframe applications using third party software. Although the cost of JavaStations is similar to low-end PCs, it is hoped that their flexibility and ease of administration will save companies money in the long term.

On the software side, JavaSoft has introduced the "100% Pure Java" initiative, to ensure that third-party virtual machines and class libraries are fully compatible. However, many developers do not believe it is possible to write "100% pure" code at the moment, and Sun recognises that it will be some time before the developers are prepared to commit entirely to Java. A particular problem may be Microsoft, who wish to optimise Java for Windows, and create Windows-specific virtual machines.

One company that is committed to the "100% Pure" initiative is Corel, who are currently re-implementing Corel Office in Java. The suite of programs, now available as a beta version, includes Word Perfect, Quattro Pro, Corel Chart, Corel Presentations and a desktop environment.

Looking further ahead, Java is likely to be submitted to the International Standards committee, though probably not until it has been through several more releases. The next major release, Java 2.0 is planned for mid to late 1997.

Glossary

API
acronym for Application Program Interface. This is the interface between the high level programming language and the provided functions
Applet
A program written in Java to run within a Java-compatible web browser, such as HotJava or Netscape Navigator. Applets differ from full Java applications in that they are not allowed to access certain local resources such as files and serial devices (eg printers).
Byte_code
low level instructions, not for a particular piece of hardware, but for an abstract virtual machine. Byte code is the virtual machine's equivalent of machine code. Java code is complied into byte-code which is then run by the Java interpreter.
Object
The principal building blocks of object-oriented programs. Each object is a programming unit consisting of data and functions
PDA
Acronym for Personal Digital Assistant
virtual machine
'An abstract specification for a computing device that can be implemented in different ways, in software or hardware.'

Further Information

Graphics     Multimedia      Virtual Environments      Visualisation      Contents