|
|
1. OBJECT ORIENTED PROGRAMMING LANGUAGES |
Java is an object oriented language, i.e. it follows the object-oriented paradigm. Object oriented programming is currently extremely popular although the concept has been around since the early 1970s. A brief overview of well known object oriented languages other than Java is given below (listed in chronological order):
|
There are many more, but the above are the most significant. |
2. ORIGINS OF JAVA |
The Java language started life in 1990 when a team at Sun, headed by James Gosling, designed a new programming language, known as Oak, for the development of consumer electronics software (the Green Project). It was not till the introduction of the WWW that the language Java came into being. With the introduction of the WWW the Oak development team quickly realised that Oak style programs could be invoked over the Internet using what has become known as a Java Applet. The significance of this is that the language would be completely "platform" independent ---- remember that previously to run (say) a C program on a PC platform you needed a PC compiler and to run the same program on a UNIX platform you needed a UNIX compiler, Etc. To demonstrate this Sun developed the worlds first Java enabled Web browser and called it HotJava.
This platform independence sets Java apart from any other language. However, Java programs do not have to be run from a Java enabled WWW browser, they can be run independently as applications in the traditional manner. As a relatively young language (compared to languages such as Ada or C) Java is still evolving. The core of the language is small (with respect to other "OO" languages such as C++), however more and more packages (libraries) are constantly being added. Version 1.0 of the language was launched, by Sun, in 1995. Version 1.1 was produced in 1997, and included minor modifications to the core language and major additions to the libraries. Version 1.2 came out in December 1998 and included many significant changes that resulted in this version being referred to as "Java 2" and then as the "Java 2 Platform". Version 1.2 was followed, in 2000, by version 1.3. The current version (summer 2003) is 1.4, and this is the version we will be using. |
One way of running Java is to use the Java 2 SDK --- Software Development Kit (previously known, with respect to Java Version 1.1, as the JDK --- Java Development Kit). There are three editions of Version 1.4 of the Java 2 Platform and the Java 2 SDK:
2.1. Java "Enabled"The term Java enabled means that inside the browser there is a hypothetical machine known as a Java Virtual Machine (JVM) which can run Java for that particular computer. The Java that comes over the net when an Applet is invoked is encoded in something known as Java Byte Code (JBC). A JVM resident on a particular computer can interpret JBC and consequently "run" the Applet on that computer. 2.2. Programming in JavaFrom Section 2 we have seen that we can write two different kinds of Java program:
We will be focusing on the first of these approaches. |
3. THE MECHANICS OF CREATING AN EXECUTABLE JAVA "APPLICATION" PROGRAM |
Figure 1: The mechanics of creating an executable Java program.
4. PROGRAM EXECUTION |
In the case of languages such as C, C++ and Ada, once code has been compiled the result may be run (executed) through a command to the operating system comprising the name of the program (without any suffixes). However, in the case of Java --- to achieve the desired platform independence --- the Java byte code must be interpreted using an interpreter. Assuming the existence of a Java Byte Code (JBC) file called Mypro.class this can be achieved as follows: |
java Mypro Java can thus be viewed as a cross between a compiled high level language and an interpreted one. Note: Remeber that the alternative way of invoking a Java program is by writing it in the form of an Applet and invoking it from a (Java enabled) WWW page --- however this is not of interest to us at present. |
5. APPLICATION PROGRAMMING INTERFACE (API) |
In Sub-section 3.3 we noted the existence and usage of the "packages" concept. Many programming languages provide a set of packages to support common operations such as Input and Output (I/O). Collectively the preprogrammed classes contained in the Java packages which are provided with the language are called the Application Programming Interface or API (a term also common to many programming language and not just Java). The Java API consists of a large collection of classes (hundreds) organised into different package (each package thus contains a number of classes). Currently (April 2005) the Java API comprises some 30 packages (some of which comprise several sub-packages). A package can therefore best be described as a collection of classes which logically fit together. The most commonly used packages are:
|
We will only be considering the first three of these. We can inspect individual packages and their constants through Sun's Java WWW page at http://java.sun.com. If you go to this page and select "API Specifications" (listed near the top on the menu on the left under "reference") this will take you to another page ( http://java.sun.com/reference/api/index.html). If, under "Standard Edition", you now select "J2SE 1.5.0" this takes you to an extremely useful page ( http://java.sun.com/j2se/1.5.0/ docs/api/) shown in Figure 2. It is a good idea to add this URL to your bookmarks/ favourites. All the packages currently available are listed here (and all the classes). If you select a package this will bring up a new page listing all the classes in that package. By selecting an individual class you can then inspect the features of that class, and so on. For example if we select the package java.lang (which provides classes that are fundamental to the Java programming language) and then "scroll" down the class summary and select the class system you will see a summary of all the fields and methods contained in this class. |
Figure 2: The Java "J2SE 1.5.0 API specification" home page
(Remeber that the java.lang package is always automatically incorporated into every Java program.)
6. JAVA INTEGRATED DEVELOPMENT ENVIRONMENTS |
There are a great many Java integrated development environments (IDEs) available (Sun's J2SE is not an environment). Examples include:
|
All these are available for PC platforms using Windows 2000 or NT or later. There is also a version of Code Warrior that will run on Macintoshes. An additional advantage offered by some of these environments is that they can outperform the J2SE in speed. A word of warning however, most environments come with their own built-in Java compiler which may not be the latest version (Java is upgraded by Sun at intervals) --- to upgrade such environments a new version must be obtained --- at cost!. |
Created and maintained by Frans Coenen. Last updated 10 February 2015