Contents Up Previous Next Web Site Home Page

Quick Page Reference...

A Brief History of Java

What is an Applet?

Applets and other technologies

Compilers & Interpreters; Bytecode

Java and your browser - the JVM

Java Software Development Kit

Integrated Development Environments - IDEs

Introduction to the basic SDK tools

QuickCup: Basic Principles - A Brief History of Java

Java was originally started as an elite project codenamed Green to find a way of allowing different electronic devices such as TV-top boxes and controllers to speak a common language. This was originally dubbed Oak but failed to find a niche despite its potential.

In 1993, the first web browser Mosaic was born, revolutionising the internet from an environment for educators and scientist to one taken up by a ever-increasing cross-section of people from all walks of life.

This changed the (now a company called First Person) team's focus to producing a software system for online multimedia. The decision was made to give the source away free on the internet.

The first oak-ready browser, WebRunner was created with the first ever applet, showing a character called Duke (which can now be found throughout Sun's Java web site) waving back at his parents. Sun decided to rename the language, to become Java.

WebRunner became HotJava due to a trademark conflict, and then in 1995, Netscape signed a deal with Sun to incorporate Java technology in its hugely popular web browser. The uptake has increased ever since.

Java has now evolved into a programming language that can be used across different computers, electronic devices, and internet browsers without having to produce different versions of the program to suit each one. This has always been a major problem for the software development industry, or lone programmer wishing to reach the widest possible audience.

How can Java be used?

We will be concentrating on using Java to attract interest in your web pages, and giving you the fundamental understanding of programming to go on to create Java Programs to suit your own purposes.

However, Java has been taken up voraciously by many developers across all major industries, and the need for Java programmers has thus rocketed, such that demand far exceeds supply. For this reason, Java programmers are currently earning good salaries (typically £30-£40k+) and enjoying being on the cutting edge of technology.

So why has Java been taken up by big business as well as the small developer producing a web site, or simple applications to share with net surfers?

The biggest reason is interoperability or the ability to write a Java program for one computer, and be able to run it on virtually any computer that can run Java programs (and due to Java's popularity, most computers can) with little or no change in the program. This might seem an obvious need, but until Java, there was no universally accepted language that could work across different types of computers.

Java can be run on computers called web servers - these are the computers that you are linking to when you are browsing the web, and contain web pages to send back to your computer, or instead, programs that determine how the web pages should look when they are viewed on your computer.

So Java can be run on servers as well as clients (that's your computer when you're browsing the internet) - another advantage. It can also be used to link to stores of data called databases, it can control how to communicate with other computers across the internet in a variety of ways, it can create real-time three-dimensional games that run from your web browser. In short, it can cope with the majority of common computing tasks that you choose to throw at it.

Finally, Java can also be used to program electronic devices - and as a result of its innate ability to talk to other computers across the internet, this allows for devices that can talk to each other, or that can be controlled across the internet from, say, your web browser. Uptake for this technology has been quite slow, largely due to this being a fairly young and volatile part of the industry, but is increasing.

So what are it's shortcomings? Well, Java is owned by Sun microsystems, who thus control how it develops, although they do generously allow anybody to freely download the tools required to get going with programming in Java (the JDK - Java Development Kit). This means that other companies who wish to produce competing products (e.g. Microsoft with its .net project) will naturally wish to squash its use in  industry as much as possible. For example, in the Microsoft's latest Windows XP operating system, Java does not come bundled with the web browser as it has done before - you will need to download Java from Sun's web site before Java Applets will work OK. However, many computer manufacturers such as Dell and Compaq have chosen to pre-load Java onto their new PCs, so this may not be a real problem.

Java has traditionally had a reputation for being slow. This is inevitable, as the programs must be independent of the different languages that different computer processors understand (known as machine language or machine code). However, as processor speeds have increased, and Java technology has improved (with such help as Just-In-Time Compilers - where the code gets converted into machine code just when the Java program is about to be run) this barrier has been less noticeable.

Despite Microsoft's competition, Java looks set to maintain prominence in the computing world - partly due to its continuing evolution, partly because a lot of people are now using it, and partly because it has such a solid basis on which to build virtually any type of application, aided by the frenzy of activity in trying to get anything and everything connected to the internet.

Indeed, a recent report released by Evans Data Corp [eWeek 16-08-2001] indicates that in the US, Java is set to overtake the use of both C++ and Visual Basic next year, with an estimated 60% of developers using Java.

What is an Applet?

An applet is a Java program which can be put on a web page amongst the rest of your content . If you browse the web regularly, you will undoubtedly have come across examples of Java Applets - they tend to start as grey boxes which burst into life once the Java program has been loaded and starts.

Creating an applet is a fairly simple process:-

A more technical explanation of an Applet is that it is a Class (or program) that inherits (reuses) the details of the Applet Class, and uses and extends these details to form an application that can be used within a Java-enabled web browser. The first sample of a Java application given later in this session will demonstrate this more effectively than this somewhat vague description.

Applets and other technologies

So what's the point? There are alternatives to Java. Let's go through a few of them and highlight a few pros and cons:-

Platform Pros Cons
Java Free; Well-used; Extensive capabilities; Lots of good on-line resources; Multi-Platform; Programmable;
Transferrable skills.
Not compiled, so fairly slow; Daunting to the beginner;
Tools for Java tend to be geared to the programmer.
     
Flash Commercially supported; Fast (to paint & load) animations; Geared to presentation; available on several platforms; Programmable if purchase developer version. Costs £300+;
Restricted Programmability;
Updates infrequent;
Skills not transferrable to other types of programming
     
DHTML Free; Special graphical effects, including moving objects; Programmable On-line resources limited; Little used; Incompatabilities between browsers; Limited effects and programmability.
     
JavaScript / HTML Free; Well used and known; Good on-line resources; Programmable;
Good for form-filling and triggers,
Limited capability; Relies on page being static; 
     
GIF animations Free tools available; Animations or still pictures Not programmable; GIF format is patented; Image can be animated, but cannot itself move.

  It is not uncommon to mix these methods, even in the same page, according to the suitability to the task - e.g. use GIFs for banner ads, JavaScript and HTML for form-filling, and Java for a more interactive section, or news-banner.

Common uses for Java Applets might be to create interactive games (e.g. arcade games, crossword or other word-puzzle, etc.), to show scrolling banner-style text, to create graphical eye-catching animations, to connect to another computer (e.g. using a Telnet or Chat session), and so on...

Compilers and interpreters; Bytecode

When you write your list of instructions for the computer to perform a task, called a program, you have to write it using one of the many available programming languages available today - Java, C, C++, Pascal, BASIC etc. etc.

Once you have created your instructions, you will need to start a program called a compiler, which will take your instructions, an translate it into a form understood by the computer that the program is being created on - effectively, it translates a language you can understand reasonably well to a language the computer can understand.

Many compilers have an in-between stage, where the original program (source code) is converted to something called object code - this is often used to package up procedures into libraries, so that they can be distributed to other programmers, without them being able to see (and thus copy) the original source code. It also tends to be a lot smaller in size than the original source code, and can also be scrambled for extra security.

This object code can then be converted into machine code.

Java goes one step further. When a Java program is compiled, it produces a language known as bytecode - which is quite similar in principle to object code. This bytecode can be packaged into libraries, but even more useful, the same bytecode will be created whichever computer is being used. Thus, the bytecode can be used on any computer, and is a lot more efficient to execute than the original source code, if not quite as fast as the computer's machine code.

The final stage is that the bytecode is read by the Java Virtual Machine, and translated to machine code as it reads the bytecode.

Thus, the bytecode can be used on any computer that has a copy of the Java Virtual Machine on it - i.e. most computers with Web Browsers.

Java and your browser - the JVM

The Java Virtual Machine is a rather grand sounding name for quite a simple concept.

In days gone by, there were several languages (as we saw earlier), each of which would compile (produce) different final machine code (i.e. language that a computer can understand). Moreover, each type of computer, and operating system (e.g. Windows 3.1, Windows 95, Windows 2000, Unix, MacOS, etc.) would need to produce different machine code for the specific machine/operating system combination.

In simple terms, each computer speaks a different language, and programmers were writing in different languages too. And then everyone wanted the different programs/computers to talk to each other. Mayhem and confusion ensued.

The Java Virtual Machine and the Java language sought to remove this confusion. The Java Virtual Machine is a translator that takes the highly optimized (i.e. designed to execute as quickly as possible) Java Bytecode (described in the previous section) and converts it into machine language that is understand by a specific computer.

Thus, every computer that has a Java Virtual Machine can run Java programs. And most computers (desktops, laptops, servers and hand-helds) do have a JVM, because it makes the computer more appealing, as it can then execute a lot of programs written in Java.

In fact, it is possible to take programs written in other languages than Java, and convert them to produce Java ByteCode - thus, the original language you wrote the program instruction in, does not necessarily even need to be Java. There are obviously complications with this!

One note - after version 1.1 of Java, the Java Plug-in was introduced, which introduced new facilities for better Java applications. This 'plugs-in' to your browser so that it can run Java applications, but web pages that make use of v1.1 or later must use applets in a slightly different way. One further advantage of this is that although Microsoft has not updated the version of the Java JVM in its browsers since version 1.1, the plug-in it can be downloaded from Sun to give the latest enhancements, and as a plug-in, can be downloaded automatically when your browser detects it is needed. 

The Java SDK (Java Development Kit)

The Java Development Kit (JDK) is a set of programs that form the basis of writing applications in Java. They are available for free (downloadable from the java.sun.com site). The JDK also contains documentation, samples, and a full class library that lets you perform a host of tasks on your computer.

The tools include a compiler for translating the Java source language to bytecode, a Java Application (bytecode) runner, a Java Applet (bytecode) runner, a documentation tool, a library packaging tool, several security tools, and several other smaller utilities.

As the JDK is freely available, we will be using this for the majority of our work.

Integrated Development Environments (IDEs) - QuickCup

There are also available several tools that build on the JDK to provide what is known as an IDE (Integrated Development Environment). This combines several of the tools, plus form-designing and on-line help in a single application. This can be very useful for larger-scale projects, but can take some getting used to. Sun provide a free-to-use application called Forte for Java Community Edition, and Borland provide an excellent tool called JBuilder 5 PE (Personal Edition).  There are several other products from industry leaders such as IBM, MicroSoft, and Symantec.

We will be utilizing a smaller IDE which is adequate for the purposes of creating Java Applets for the web, and much easier to learn than the tools described above. The application is called QuickCup and has been written by the author of these notes with teaching a Java Course in mind. The application is FreeWare, so feel free to distribute it to others (but not for profit) or use it yourself at home. 

The application QuickCup lets you create Java projects, into which you can add any java / html etc. source files, and edit, compile, test and package them for distribution. However, it doesn't cater for more involved tasks, such as integrated debugging, form design, and context help. More on QuickCup later.

Introduction to the basic SDK tools

The JDK has a number of tools. These are listed below. The most important program must be javac which checks your source code to see if it is correct, and if it is OK, generates java bytecode. You can then test that this works OK using either the appletviewer program, or direct from your web browser!

Pretty straightforward!

Text Editors

It may seem odd that one of those tools is not a source code editor! This is because an editor is something that tends to be an individual choice, and every computer has its own standard text editor(s), so this is not a necessary part of the JDK tools.

A text editor is a program, rather like a word processor, that allows you to type in source code (e.g. Java language commands), save them to a disk file, print them out, and change them to correct problems or add extra commands.

The standard text editor for PCs running a variant of windows is the notepad program. To start-up notepad, click on the Start button at the bottom-left hand corner of the desktop, click on the Programs menu, then the Accessories menu to the right, and finally click on the Notepad application.

You may choose to use Notepad in your own development, as it is available on all PC Windows computers. However, we will be using the QuickCup IDE.

Program Description
javac The Java compiler. Converts Java Source Code into bytecode.
java / jre The Java interpreter. Takes bytecode (stored in .class files) and executes it in a language that the computer understands.
appletviewer As java, but takes a HTML file and runs an Applet as it would appear in a browser.
jar Java ARchiver program. Creates JAR files, which are libraries of multiple Java Classes and resources, packaged up into a single compressed file. Great for distributing an application, for example, via the internet.
javadoc Java source code documentation generator program. Creates HTML documentation based on the source code, and the comments within the source code.

There are several other applications within the JDK tools, but these are for advanced use - e.g. relating to security, testing server-based Java applications (servlets), Remote Method Invocation, Debugger etc.

 


(c) Copyright 2001-2 Arctan Computer Ventures Ltd.   All Rights Reserved.
If you have any issues regarding this on-line help, please contact the author by clicking here.
This Page was last updated: 26 April 2002 15:54