Computing in the real world
SEARCH FOR: IN:
Guest  Level 00    Register Log in

News 

[PSUs]
Wednesday 21st November 2001
A lowdown on... Java 4:22PM, Wednesday 21st November 2001
Java. Java. Java. Chances are any new release from a wide range of technologies - from mobile phones and PDAs to Web programming and enterprise servers - will make reference to this seemingly ubiquitous technology.

What is it that makes Java so important? Why is it more than just another programming language? And why, exactly, has Microsoft not fallen under its spell? Time for a lowdown...

Contents

- What is Java?

- History

- Where Microsoft fits in

- The makings of a baggy monster

- Sample code

- Java installations

- Resources

What is Java?

In a nutshell (or bean, perhaps), Java lets you build systems that are platform-independent, capable of running across networks (including the Web) and - because it's a full-featured programming language - it can bring a new level of standardised functionality to small and previously dumb devices. It is possible, for example, for very small devices to access very large databases by means of well-tested function calls. It also supports fine-grained access and security profiles to police the behaviour of distributed programs. Essentially, it has offered the promise of programming the Web to good effect.

In slightly more detail, Java is a class-based, object-oriented language created by Sun Microsystems (slogan: 'the network is the computer'). It is heavily based on C++, which is the king of the jungle as far as programming languages are concerned, with its heavy-duty support for a variety of programming techniques and its wide professional usage. The developers of Java, however, sought to simplify things and to add a number of features for the networking world (and ultimately that meant the Internet).

In technical terms, the Java creators added features such as garbage collection (the automatic tidying up of unused variables) and support for explicit multithreading. They also removed some difficult C++ features, such as operator overloading (the ability to adapt the language to user-defined objects) and support for multiple inheritance (that a user defined object could be derived from multiple 'types' of ancestor rather than a more straightforward single inheritance).

More importantly, Java was designed from the start to execute across a network, securely. As well as the elimination of the use of pointers, which languages have traditionally used to access specific addresses in memory, the language was designed to be cross-platform even at an executable level (most languages are cross-platform in source-code form, in the sense that you have to recompile programs every time they are to run on different machines). The way Java approached this was to use intermediate byte-code rather than fixed, compiled binary. Essentially, programs are decoded on the fly by Java platform-specific Java interpreters.

These JVMs (Java virtual machines) are built for various platforms and provide a consistent, known environment for Java programs to run within. Java's slogan is 'write once, run everywhere' because, in theory, once a program is written in Java it can run on any JVM supported on any machine. The 'logic' of the program will remain unchanged because it can safely make assumptions about what will be provided when it tries to execute - the particularities of the machine that hosts the program will be taken care of by the particular runtime environment for that machine.

History

A bit of history. Back in the early nineties James Gosling was working on the 'Oak' programming language out of which Java would grow. This was part of a Sun-sponsored project to target smart consumer electronic devices, such as TV set-top boxes.

By 1994, the First Person project was abandoned, but this didn't spell the end for the language. Sun presciently realised that the same constraints for programming consumer devices - the ability to run within a 'small footprint', platform-independence, and the maintenance of security - also applied to the daddy of all networks, the Internet.

Gosling, along with Mike Sheridan and Patrick Naughton, proceeded to shape the language that is globally used today. All that was needed was a name change - something vaguely 'cool', universally recognised and thus easy to market... 'Java'.

This very brief version of Java history, by the way, is based on comp.lang.java FAQ list.

Today, Java is widely used in both commercial and academic worlds - it has largely overtaken both Pascal and C++ as the default language for teaching computer programming.

Where Microsoft fits in

Only recently, Sun has announced a preview version of a JVM for Windows XP. 'We're committed to delivering the best interactive user experience on the Web through Java technology,' said Rich Green, a VP at Sun. 'The Java platform has achieved incomparable success in the software industry as a fundamental foundation for end-to-end cross-platform architecture for everything from the enterprise to mobile phones. Sun continues to build on this success by delivering cutting-edge support for Java technology for the Windows desktop.'

You might think Microsoft would welcome its latest version of Windows joining the family of platforms capable of supporting Java, but things are slightly more complicated than that. There are two main issues regarding Java and Microsoft.

First, the two companies have already fought a legal battle over Microsoft's version of Java (Visual J++). The court found in Sun's favour that Microsoft had deliberately made its version of Java incompatible with the de-facto standard, thus undermining the 'write once, run everywhere' premise of Java. Effectively, if Microsoft 'embraces and extends' what Java can perform, then the supposedly platform-independent language rapidly becomes implementation-specific.

Theoretically, you should be able to write a Java program and (within reason) get the same results on any machine that can support running Java code. For example, imagine creating a little program to write 'Hello World' to the screen. For a Windows program, coded in C or C++, you would have a particular set of API calls to manage the Microsoft windowing environment (create a window, display it, load a font, etc) and then the particular command to start writing a piece of text. Java, by contrast, essentially 'abstracts' this problem into the essence of 'display text on a screen'.

For example, for a running Java applet, the details of the graphic device-context will be handled by the device's virtual machine. You just 'write to the screen' and the local environment manages this, as sensibly as it can, within its local context. JVMs running on a mobile-phone
 
 
ADVERTISEMENT
or on a Windows-based PC or on some special display device, would handle the request differently in the physical details, but 'logically' the program can remain unchanged. Of course, completely platform-agnostic applications do not always make sense - full-featured video editing on a watch, as an extreme instance. But this generalised approach often promises a better solution than, for example, HTML being 'repurposed' as WML (Wireless Markup Language) in order for a Web site to appear on WAP phones.

Do you see why Java may not be the most popular programming language for Microsoft and its domination of computing with its privileged control of the Windows platform? Not only is a rival company - Sun Microsystems - controlling the standards, but Windows becomes just another platform not the dominant, singular system that is inconveniently incompatible with most other systems.

The second main issue concerning Java and Microsoft is .Net. Microsoft has come relatively late to the Internet game, but now its whole strategy revolves around its .Net framework, which in turn is based on its own (Java-like) language, C##. Rather than going the route of building on Java as a global lingua-franca for delivering Web services, Microsoft has chosen to take the project 'in house'. Hence the arrival of C##. Naturally, it now has greater control over the pace and implementation of .NET.

A detailed comparison of Java and C## can be found here.

The makings of a baggy monster

As Java has become more established over the years, it has grown to fill ever-more areas of computing. Some of these are niche markets, some of them are growing computing phenomena, such as the importance of cell phone-based communications. For example, there are Java APIs (Application Programming Interface - sets of pre-defined function calls) for controlling digital televisions, operating embedded devices and communicating with networked application servers working in huge enterprise environments.

In an attempt to tidy up and rationalise what was becoming a bit of a baggy monster, Sun created a number of distinct 'editions' of Java, each relevant to different major types of application. This came with the creation of the Java 2 platform.

Whereas Java had been evolving in minor point releases - eg 1.1, 1.1.3, etc - the decision was taken to explicitly emphasise a major revision in Java's evolution. The creation of Java 2 (what would have been something like Java 1.4 under the old naming scheme) also saw the creation of the three editions: standard, enterprise and micro.

STANDARD EDITION

This involves core elements of Java, including the Java 2 SDK (software development kit) and associated tools. This is backwards compatible with earlier Java development kits, such as JDK 1.1.

ENTERPRISE EDITION

This is a framework for using Java within an enterprise-scale computing. It covers such areas as fail-over and load-balancing and other serious, large-scale server-side issues.

MICRO EDITION (J2ME)

A highly optimised version, suitable for embedding within a range of consumer electronics, such as pagers, cell phones and digital set-top boxes.

Sample code

By now, you may be wondering what Java actually looks like. This is not the place for an introductory tutorial - there are links for that further below - but it is nice to show what the 'magic code' actually looks like. A small taster for what Java programmers have to work with.

Here's the traditional 'hello world' program, which outputs a simple message. This is what it looks like in 'Application' form. (Generally speaking, a Java application is a stand-alone program with privileged access to the host computer.)

/*

Display "Hello World!" to the standard output.

*/

class HelloWorldApp {

public static void main(String[] args) {

//display the text

System.out.println("Hello World!"); }

}

Here's the same functionality in 'Applet' form. (An applet is a program running within the context of another program, such as a Web browser. Generally, it will have limited access to the system it is running on.)

import java.applet.Applet;

import java.awt.Graphics;

public class HelloWorld extends Applet {

public void paint(Graphics g) {

g.drawString("Hello world!", 50, 25); }

}

Java installations

You may have a Java environment installed on your PC without being aware of it, perhaps installed to support the Java features of an application. For example, under a JavaSoft directory, I have a Java 1.3.1 Runtime Environment, with bin and lib subdirectories for binary executables and library files. I didn't explicitly search this out - it was installed as part and parcel of an application that required Java support for some of its features, for example the Opera browser.

This runtime environment supports the use of Java on your machine - Java can execute within this space. As long as a machine has runtime support for Java - and a Mac's support will differ from a Unix box, which in turn differs from a particular Windows platform - the application can carry out its functions.

Resources

If you are interested in finding out more and looking into Java in more detail, here are a few sites of interest on the Web.

Sun Microsystems, as you would expect, has a wealth of material on Java, from the perspective of both users and developers. Here are some of the main ways into its online content:

java.sun.com/java/

java.sun.com/getjava/

java.sun.com/docs/books/tutorial/

Here are some guides to getting started with Java code yourself:

developer.java.sun.com

developer.java.sun.com/developer/onlineTraining/Programming/BasicJava1/

developer.java.sun.com/developer/onlineTraining/Programming/BasicJava2/

Finally, numerous third-party sites also focus on the Java programming language. Type the keywords into your search engine of choice and you will be inundated. Here are just a few to get you started.

www.javacoffeebreak.com

www.gnu.org/software/java/java.html

www.javaworld.com

www.javareport.com

www.javapro.com

The low-down on programming languages

The low-down on .Net

Submit to: Digg  |  Slashdot  |  Del.icio.us  |  Technorati

Related News



Compare Broadband
Broadband?
Compare 50+ packages
Enter your postcode below:
Powered by:
Top 10 Broadband
Bookstore Top 5

Columns

Prolog:

Tim Danton goes in search of the cloud and discovers something strangely tangible. › See full Opinion