jchap_0 about java, jdk & bluej (prof. ananda m ghosh.)

27
Chapter 0: About Java, JDK and BlueJ 0.0 Introduction Java is a high level programming language. A programming language is called high level when its statements/expressions look similar to a natural language, say English. Of course, no computer hardware can understand or execute instructions given in a high level language unless the same is translated into its hardware understandable binary words. For this reason, every high level language needs appropriate compiler or interpreter for its translation into computer understandable binary forms and formats. There are, at present, many popular high levels programming languages like, Fortran, Cobol, C, etc. Each of these languages was developed to meet some specific need of applications. Fortran was developed for scientific applications, Cobol for business applications, C for easy development of System programming (like Compiler, Operating System, etc). A Fortran or a C program is nothing but a collection of variables and functional procedures or routines necessarily required for solving a complex problem, part by part. Whereas, Java is an Object-Oriented Programming (OOP) language and can be regarded as a collection of defined classes and objects interacting with each other by passing messages. Before going into any further details, let us have a look into the history of java language development. 0.1 Advent of Java Language The language C, (invented and implemented by Dennis Ritchie in 1970s), is considered to be a modern high level procedure oriented language. Adding object-oriented features with C, C++ language was developed by Bjarne Stroustrup in

Upload: prof-dr-ananda-m-ghosh

Post on 10-Apr-2015

1.654 views

Category:

Documents


6 download

DESCRIPTION

To learn Java language by a first-time learner how JDK and BlueJ tools can help

TRANSCRIPT

Page 1: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

Chapter 0: About Java, JDK and BlueJ

0.0 Introduction

Java is a high level programming language. A programming language is called high level when its statements/expressions look similar to a natural language, say English. Of course, no computer hardware can understand or execute instructions given in a high level language unless the same is translated into its hardware understandable binary words. For this reason, every high level language needs appropriate compiler or interpreter for its translation into computer understandable binary forms and formats.

There are, at present, many popular high levels programming languages like, Fortran, Cobol, C, etc. Each of these languages was developed to meet some specific need of applications. Fortran was developed for scientific applications, Cobol for business applications, C for easy development of System programming (like Compiler, Operating System, etc). A Fortran or a C program is nothing but a collection of variables and functional procedures or routines necessarily required for solving a complex problem, part by part. Whereas, Java is an Object-Oriented Programming (OOP) language and can be regarded as a collection of defined classes and objects interacting with each other by passing messages. Before going into any further details, let us have a look into the history of java language development.

0.1 Advent of Java Language

The language C, (invented and implemented by Dennis Ritchie in 1970s), is considered to be a modern high level procedure oriented language. Adding object-oriented features with C, C++ language was developed by Bjarne Stroustrup in 1979 at Bell Laboratories, New Jersey. C++ sets the stage ready for Java language development.

Java was conceived in 1991 by a group at Sun Microsystems, Inc. The initial name “Oak” was replaced by the new name “Java” in 1995. The initial motive behind Java invention was to meet the demand of having a platform-independent or architecture-neutral language so that codes can be embedded within any static or mobile devices without taking any additional burden of compilation for different CPUs. Gosling and others could find out a solution by inventing the language -- java. In mid-1990s, during java’s development period, World Wide Web and Internet applications started coming up in vogue. Thus the question of software downloading and using that for different types of computers, operating systems, and CPUs became most important and java was supposed to take care of all such requirements.

Java is ultimately found to be the most suitable language both for general-purpose programming as well as for mobile and Internet programming. Java’s applets are tiny java programs that can be dynamically transmitted over an Internet and executed by a Java compatible Web Browser. Use of applets is very popular to-day.

Page 2: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

0.2 Software Development

Software development has two aspects -- i) how requirement analysis & system design can be made easy and quick and ii) how coding, testing and maintenance of software can be made efficient. Software developers, while using function oriented languages, experienced many difficulties with respect to both of these aspects. They were in continuous search of a better high level language keeping in mind the importance of object oriented programming. Java emerges as an outcome of that search and found to be most suitable for meeting all modern age application requirements.

Java is an Object Oriented Programming language. From requirement analysis and design point of view, identification of physical objects interacting in a real-life system is much easier and straight forward. After identification of physical objects, classification of software objects become very easy. Moreover, as all objects are capable of taking some actions, procedures, required by each one of them, can be traced out easily by an analyst. Thus software development becomes entirely class/objects oriented. A software module becomes as small as a simple class size, and code generation, testing, integration and maintenance of a complex program become much more easy and flexible.

0.3 Advantages of Object Oriented Programming

1) In real life, we find presence of many physical objects with separate attribute values but capable of showing the same kind of behaviour. Such objects can communicate with each other by passing messages (i. e. asking to take some actions) and get any complex task performed, step by step. Software developers can imitate such real-life situations within a computer program to solve computational problems. This is exactly what is done in an Object Oriented Programming (OOP).

Java program is nothing but a collection of defined class(es) and creating objects using them and allowing interactions to take place as per requirements.

2) Software requirements are bound to change with time, technology improvement and users’ modified-demands. A language, chosen for software development, must be able to cope up with such changes. How quickly and efficiently such changes can be implemented without throwing away any major portions of old programs—is another very important aspect of Software Engineering. In this regard, an object oriented language is much superior because of its built-in characteristics of inheritance, encapsulation / data hiding and polymorphism .

Without going into further details on the technical jargons – it can simply be said that Object Oriented programming is better because it supports re-use of old classes and objects, which constitute the heart of an Object Oriented program.

Page 3: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

As OOP provides encapsulation and data hiding features, a program becomes self-protected against external misuse and tampering.

3) For easy testing and verification of programs, modular programming (each module containing a limited line of codes) is essentially required. In OOP languages, use of classes and objects automatically limits the size of a module.

4) Classes and objects written for one program can be used in many other programs. This feature of re-use is further augmented due to inheritance characteristics of OOP languages. Library and user-defined Classes can be imported and shared by both local and Internet users.

5) In earlier days, structured programming concept was adopted to ensure cleaner programming style. In OOP, encapsulation of data and methods in a class or object can ensure far better structuring and can prevent unwanted use.

0.4 How is Java made Platform Independent?

As mentioned earlier, java does not require separate (full) compilers for different compiling platforms (CPU, OS etc). How can that be made possible?

Java compiler (javac) does not produce directly the machine executable binary codes but generates an intermediate image of the source program in bytecodes. This intermediate image of the source code is then placed before a java interpreter (java) to produce CPU dependent actual machine codes for execution. Java interpreter generates machine codes for a local CPU. The java interpreter portion will be different for different computer platforms, but that portion [being very small in size] can easily be loaded at run-time and will never demand for a large local memory resource.

Java’s source program is saved with an extension ( *).java . Java compiler – javac -- generates its intermediate image in bytecodes and saves the same as (*) .class file. The local interpreter java makes use of the file (*).class for taking final actions at the execution end. During execution, the java run-time environment (jre which helps running java programs in a local computer environment) takes care of all run-time errors which escaped the notice of the java compiler.

The intermediate bytecodes can be transmitted over Internet and shared safely by different users placed at different locations. The jre and browser’s Java Virtual Machine (JVM to run applets) can take care of security problems, if any. Thus java language is made platform-neutral, portable, secured, distributed and dynamic binding type by adopting language translation in two different phases.

Page 4: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

0.5 Java Development Kit (JDK)

JDK is a Software Development Kit (SDK) for Java language. It includes, along with the jre, many tools (javac, java, javadoc, debugger, etc) and class libraries that are essentially required for program development.

The first release of JDK 1.1 having a size of about 9 MB (jre size 2.7 MB only) was replaced in 1998 by JDK 1.2 which had a size of 21 MB (jre size 5.3 MB only). There after the JDK 1.3 appeared having a size of 33MB with jre of 5 MB only. The latest JDK is JDK 1.5 (size 45 MB with jre included). For the users of this book JDK 1.3 will be sufficient to provide support to the BlueJ Integrated Development Environment (IDE), which makes java learning much easier and simpler, specially for the beginners. Before we discuss about BlueJ in details, evolution of java as a language is to be examined first.

0.6 Evolution of Java

Java continued to evolve since its first release in mid-1990s as Java 1.0 immediately followed by Java 1.1 where new features like Java Beans, Java DataBase Connectivity (JDBC), Java Native Interface (JNI), etc were added. With Java 2, further new features like Swing, Collections, Java Archive (JAR) files, Just-In-Time (JIT) compiler, etc were introduced. At present, java is available in two editions -- J2SE (Java 2 Standard Edition) and J2EE (Java 2 Enterprise Edition). Like these two editions, JDK 1.3 also provides support to java 2.

0.7 About BlueJ

BlueJ is a special kind of Integrated Development Environment (IDE) for developing programs in java language. Every IDE is a window based software development facility specially designed for source program editing or correction, compilation, running programs, helping to trace out errors, displaying results through terminal window, etc simply with a mouse click on the appropriate menu items. BlueJ provides all these facilities for java program development.

BlueJ was developed at Monash University of Australia specifically for the purpose of teaching and learning object orientation with Java. BlueJ is free! You can have it from the web-site http://www.bluej.org/

[Some useful features of BlueJ (collected from the said web-site) ]

BlueJ is based on the Blue system, developed at Sydney University and Monash University, Australia. BlueJ provides a Blue-like environment for the Java language.

Page 5: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

BlueJ is implemented in Java, and can be installed under various operating systems like Solaris, Linux, Macintosh, and various Windows versions. It can run on all platforms supporting Java Virtual Machine.

The BlueJ environment was developed as part of a university research project about teaching object-orientation to beginners. The system is being developed and maintained by a joint research group at Deakin University, Melbourne, Australia, and the University of Kent in Canterbury, UK. The project is supported by Sun Microsystems.

The aim of BlueJ is to provide an easy-to-use teaching / learning environment for the Java language programmers. Special emphasis on visualisation and modular interactions has been given to encourage experimentation and exploration by users.

BlueJ offers most user-friendly development tools, better debugging, better execution control, and better output display efficiency.

0.8 More About BlueJ?

Picture 0.1 BlueJ Window

Page 6: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

BlueJ (Picture 0.1) is most suitable for the beginners because of the following: ----

It can be used with the latest version of Java.

It’s available free of charge -- an advantage not only for the laboratories but also for students who wish to work with a copy at home.

It gives a graphical representation of the classes used in a java project.

It has a built-in working debugger.

It allows you to test individual class/objects without writing any test drivers.

0.8.1 Installing BlueJ at your Computer

(Warning: These instructions are meant for Windows users.  There is a version of BlueJ for Macintoshes also, but you'll have to figure it out on your own.)

BlueJ is an interactive development tool that uses Sun’s Java compiler and interpreter.  The BlueJ installation file does not include Sun’s Java compiler & interpreter.   So before you install BlueJ, you must have to install Java in your computer.  What you need is one Java SDK (Software Development Kit).  (If you’ve heard people talking about a JDK, this is an older term for the same thing.)  If you already have a Java SDK, version 1.2 or higher, installed in your system – that will serve the purpose of working with BlueJ.

0.8.2 To install SDK (before installation of BlueJ):

Visit the Sun web site (http://www.java.sun.com/) and follow the links and instructions to download and install the most recent SDK, which as of July 2005 is 1.3.1.  (I don't recommend trying a Beta version.) 

The most recent version for Windows as of July 2005 is at http://www.java.sun.com/j2se/1.3/download-windows.html.  Alternately, start at the main Sun web site (http://www.java.sun.com/), click on "Products and APIs" at the left, then "Java 2 Platform, Standard Edition", then click on the latest version of the SDK which is not a Beta version.

Once you've found that page, scroll down to where it says "Download Java 2 SDK" and click on "continue".

Read the License Agreement (or scroll down the page saying "yeah, yeah") and click "Accept".

Page 7: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

Click on one of the download sites to download the installer.  This is a very large file and will take a long time if you're using a dial-up connection (or several minutes with a broadband connection). 

Create a new folder to hold your SDK-- I'll refer to this as your SDK installation folder.  Find your installation file (called something like j2sdk-1_3_1-win.exe) with Windows Explorer or My Computer and double-click on it.  The installation process will take a while.  Click on "Next" and "Yes" when asked, and give the name of your SDK installation folder.  At one point, you will be shown a list of components.  If you're short of space, you can uncheck everything but "Program Files".  After the installation is done, you will be asked to reboot.

I strongly recommend downloading a copy of the Java documentation.  You can browse it online, but it's much faster to have a local copy.  To get one, go back to the original download page and click on "Browse and Download Java 2 SDK, v 1.3.1 Documentation".  From there, find "Download Java TM 2 SDK 1.3.1 Docs - HTML Format" and click on "Continue" underneath it.  Accept the license policy and you'll get to a download page.  Un-zip it right into your SDK installation folder and it will create a "docs" sub-folder containing many, many pages of HTML. 

0.8.3 Installing BlueJ thereafter:

Once you've got the SDK, you can install BlueJ itself.  Go to http://bluej.org/download/download.html the download and installation procedure isn't too hard, but here are detailed steps:

Click "Download",

Choose either Windows server and click on the file bluej-114.jar to download it.  (Note: "jar" stands for Java Archive; it's a compressed file, kind of like a zip file)

Create a new folder for BlueJ -- I'll refer to this as your BlueJ installation folder.

1. Double-click on the jar file from Windows Explorer or My Computer.  If your computer is configured just right to run jar files, this will start up an Install Shield-like installer.  If that works, you're all set.  Otherwise, if you're asked what application to use to open the file, cancel and go on to the next step.

2. To start the installer from DOS, open a DOS window (Start Menu | Programs | Command Prompt).  Connect to the folder containing the jar file (for example, if the jar file is in c:\installer, you type "cd c:\installer").  Now type the command: "java -jar bluej-114.jar".  If this works, there will be a pause and then the installer window will pop up.  If your

Page 8: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

computer complains about an illegal command, your class-paths aren't set up properly to find the java executable in your SDK.  Rather than fixing your class-paths, go on to the next step.

3. If your system isn't recognizing the "java" command, you'll have to give it the full path name, which is your SDK installation folder plus "\bin\java".  So, for example, if your SDK installation folder is c:\sdk1.3, you type the command "c:\sdk1.3\bin\java -jar bluej-114.jar".

Once you've got the installer running, the hard part is over with.  Just give it the names of your BlueJ installation folder (that's where it will unpack all the BlueJ files) and your SDK installation folder (so BlueJ knows where to find the Java tools it needs to use).

0.8.4 BlueJ Documentation:

Unfortunately, BlueJ doesn't have the normal help menu stuff we're all used to.  It does have a tutorial in PDF format.  (If you don't have a PDF reader, you can get a free one from http://www.adobe.com/.)   It's a pretty good tutorial, but not well organized for getting started quickly

To download the BlueJ tutorial from the BlueJ web site, click on "Documentation", and then click on "The BlueJ Tutorial".  If you've got your browser set up to display PDF files directly, you'll see the tutorial. 

There's also a BlueJ Reference Manual available from the Documentation page.  As they warn on the web page, it's a work in progress and some helpful-sounding sections are not filled in yet, but what's there can be useful.  It may be worth checking back from time to time in case they write more.

0.8.5 Starting Up BlueJ:

To run BlueJ, double-click on the file BlueJ icon.  This momentarily creates a DOS window, which vanishes and starts showing a small BlueJ window. 

[A Space-Saving Suggestion: Once you've verified that BlueJ runs correctly, you can save disk space by deleting or backing up both the BlueJ and the SDK installation files.]

0.8.6 A Quick Start to Using BlueJ:

This section will walk you through writing and running a simple Java program with BlueJ.  Before you start, you need to understand how BlueJ views projects (Picture 0.1).  By project BlueJ means an application development for a particular purpose defining one or more classes within its folder. 

Page 9: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

With BlueJ, you can't edit, compile or run a class file existing within a project.  If a program consists of several Java files (or classes), they must be grouped together within the same project.  BlueJ creates a separate folder for each project.  As you create, compile and run the project, you will notice that BlueJ creates all necessary internal files for that folder. 

1. Start BlueJ using your shortcut.

2. Create a new project: from the Project menu, by choosing New Project.  You'll get a file open dialog; this will create the folder [say ToStartWith (Picture 0.2)] where your project files (i.e. classes) will be stored.  The main BlueJ window always

3. shows you the classes your project contains. There will be as many files as many new class-names you have entered along with a text file (Picture 0.2).  If you double-click on that text file icon (white sheet with horizontal lines and top right corner

4. folded), you will see that it is a README.TXT file, in which you can record information

Picture 0.2 ToStartWith Project containing 2 classes

about the project (including remarks about the classes) if you wish.  Use the Close button if you want to close that particular project.

5. To create a new class within any particular project from the main BlueJ window, click on the New Class button.  You'll be asked for a name.  For example, if you want

Page 10: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

to create a java class called Hallo2, type in "Hallo2".  BlueJ will automatically create a (predefined class structure) file called Hallo2 [.java]. Within the main window, you will see one black bordered yellow box (with diagonal lines at its lower portion) to appear. 

6. To edit that java class file, double-click on the newly created Hallo2 box.  This will open an editor window (as shown in Picture 0.3) with several text entries already having on it.

If you carefully examine first few lines, you will find that the first line starts with /*.......... ...... and then after a few lines of textual entries finally ends with */ .

This is a comment often used to pass some information to anyone reading the program. This type of comment is called a multiline comment, which is totally ignored by the compiler.

Single-line comments can also be used in a source program.

In Picture 0.3 you can find a single line comment as shown below --

// instance variables – replace the example below with your own

Like multiline comment, the compiler also ignores single-line comments. Such comments add clarity to a program and make software maintenance much easier. Single-line comments can start from anywhere within a line length. For example --

public class <class-name> { // starts defining a class

.............. } // end of class definition

Besides instance variables, a class may contain constructor(s) and function(s) whose general structural constructs are also shown in Picture 0.3. Carefully note them for your future use and guidance.

You can delete or modify any portions not required and can enter a new java source code according to your requirements. Suppose you would like to create a new java class "Hello”. Using the main BlueJ menu, create a class named “Hello” and opening the editor window delete everything written there and enter the following codes only.

public class Hello {   public static void main(String args [])

{   System.out.println ("hello, world!"); } // end main } // end class Hello

Page 11: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

5. Then you save it, and push the Compile button (or type control-K) to compile it.  You'll get a message at the bottom of your screen indicating whether the compilation was successful.

6. Once you see that your defined class has compiled successfully, close or minimize the editor window and return to the main BlueJ window.

7. If the compilation is successful, you will see that the diagonal hatch lines have been removed from the class box. When a compiled class (showing two short slant lines on its lower right corner) is right clicked, a pop up menu appears.

Picture 0.3 The editor window with Hello [.java] program

8. At this point, you may be looking for a "run" button, but there isn't one.  Instead, right-click on the compiled Hello classes box.  A menu box will appear showing an entry for every constructor [starting with new...] (Picture 0.4) and static method (like void main etc) used in your class. Just click on the void main (String []) method (Picture 0.4). 

A BlueJ: Method Call window will pop up; click OK button.  This will run your Program. A terminal window will pop up to show the output of your program.

Page 12: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

Picture 0.4 Pop Up Window for the Hello Class

9. By the same way run your program for a second time.  You'll see that the output from that run will be appended to the output from the first. 

0.8.6.1 About the terminal (or output) window:

1. You can view or hide the terminal window at any time.

Page 13: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

2. Even if you hide or close the terminal window, the output from all your runs will remain stored in that window.  If you don't like this effect, you can clear all output from the terminal window by choosing the Option -> Clear.

3. If you want to save the output of a program (for submission of an assignment, for example), choose Option | Unlimited Buffering.  Then run your program, and choose Option | Save To File, and your output will be copied into a text file. 

Please note that BlueJ is just a tool for development of java programs. There are other tools like Jbuilder, etc; but BlueJ is considered to be most suitable for the beginners.

However jdk1.3, or any latest version of it, can also help java program development if you are satisfied with the text based command line interactions only. Advanced programmers may prefer command line interactions to have better insight of internal details.

0.8.7 Text Based Program Development using JDK

You can easily edit, compile and run java programs without making use of the BlueJ or any other development tools. Under both Windows and Linux operating systems, if jdk remains installed, you can use command line instructions for editing source codes, and then compiling and executing any program. Here we will discuss about the steps involved in such text-based java program development.

Under WindowsXP:

1. From Windows Start button, via All Programs and Accessories, choose the c:\ Command Prompt. A text window will appear on your desktop.

2. Move to the drive and directory where jdk1.3 has been installed. Set path = x:\jdk1.3\bin; %path% where x stands for the appropriate drive. Under jdk1.3, create a new directory – say, myjavaprog -- where you can store all your java programs being developed.

3. Using any text editor (like notepad or wordpad) enter the source program which must be stored with the extension (*).java, {where (*) should have exact match with the class name where the main function exists}. Save the program as x:\jdk1.3\myjavaprogs\(*).java. For example, if the class name is Hello, the java source program should be stored as Hello.java. (See Picture 0.6)

4. Compile the program by typing the command -- javac (*).java – and the prompt will appear after a little while if compilation is successful. Otherwise error messages will appear first before the prompt reappears.

5. After successful compilation, (*).class file gets created in the directory where the (*).java source file exists.

6. For execution, type the command-- java (*).class – followed by a click on return key - and the output will be displayed on the same window.

Page 14: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

Note:

(i) For Command prompt interactions – don’t forget to press return key after every command line entry.

(ii) The main () function must be written as

public static void main (String args[]) and never as public static void main()

[use of String args[] is a must].

Under Linux:

1. Create a Linux terminal on the Desktop. Move to your home directory and make a new directory named (say) myjavaprog, to store all java programs files under a single directory.

2. Using vi –editor, enter your java source program and save that in the newly created directory.

3. Type the same command line instructions [as shown in steps 3 to 5 under Windows] for compilation and execution of the program.

Please note that every reader should start learning Java language using BlueJ environment first to become familiar with the foundation concepts of object-oriented programming. Gaining some experience one can choose any other development environment of his or her choice .

0.8.8 Importing a class or java file: [Skip, if you are a fresher]

Suppose you want to take support of an existing java file (i.e. class) in your program.  For example, suppose you want to modify the Hello program to take input from keyboard using the readLine() function of the SavitchIn class, as follows:

public class Hello { public static void main (String args []) { System.out.print ("what is your name? "); String yourName = SavitchIn.readLine ();  System.out.println ("hello, " + yourName + "!"); } // end main } // end class Hello

To make this program work properly, you'll have to put a copy of the SavitchIn class into your project folder.  From the main BlueJ window, choose Edit | Add Class From File.  Select the java file SavitchIn.java (You can get it from http://www.cs.queensu.ca/home/cisc124/2001f/SavitchIn.java.). BlueJ will make a copy

Page 15: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

of this file and put it into your project folder.  Compile both Hello.java and SavitchIn java files by choosing Tools/Compile from BlueJ main window. 

Now you've seen how to create, compile, and run a program using more than one class in a project.  That's enough to start with.  BlueJ has other very useful features, which you will learn gradually. 

0.9 About the Scope of this book

Java does counting in a sequence of 0,1,2, 3, ...... etc. For that reason, this book also has started with the chapter 0 that contains all introductory features, facts, figures, and reports, comments and remarks about Java, JDK and BlueJ. Although this book is mainly intended for students with no OOP programming experience, advanced programmers, who are not previously exposed to java language and BlueJ IDE, will also be benefited.

A beginner is supposed to develop a clear idea about two aspects of Java --- Java as an Object-Oriented programming language and the beauty of having a support of Integrated Development Environment (IDE) like BlueJ.

Correct Java programming depends entirely on the concepts of object-orientation.

BlueJ -- is the most suitable IDE for all categories of beginners involved in teaching-learning process of Java language. The reasons are: ---

1) Its graphic user interface (GUI) is very simple and easy to use.

2) It supports important teaching tools not available with any other development environments. BlueJ automatically displays a Universal Modeling Language (UML) -like representation of classes and relationships between interacting objects involved in a project. Such Visualization is a great help to both teachers and students in building foundation concepts.

3) “One of the most important strengths of the BlueJ environment is the user's ability to create directly objects of any class, and then to interact with their methods. This creates the opportunity for direct experimentation with objects. Students can almost 'feel' what it means to create an object, call a method, pass a parameter or receive a return value.”

4) “BlueJ is a full Java development environment. It is not a cut down, simplified version of Java for teaching or learning. It runs on top of the Sun Microsystems' Java Development Kit (JDK), and makes use of the standard compiler and virtual machine. This ensures that it always conforms to the official and most up-to-date Java specification.”

Page 16: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

5) “Because users can create and interact with objects directly, concepts such as classes, objects, methods and function parameters can easily be discussed in a concrete manner before looking even at the first line of Java syntax.”

0.10 The design of this book has made use of “Project-driven approach “

Almost all chapters provide a good number of practical examples with java source codes. Simple projects have been chosen to illustrate the important concepts discussed in each chapter. Each concept is revisited in a different context after it is introduced.

The implementation for all the projects is written very carefully, so that many peripheral issues may be studied by reading the projects' source codes. One cannot deny the benefits of learning by reading and imitating the sample programming examples.

0.11 Chapters have been arranged on Concept sequence

It is easier for students or beginners to follow the motivation of each chapter by studying the worked out examples, and then realizing the concepts behind them.

Chapter 1 – Foundation Concepts of Class and Objects gives introduction to the most fundamental concepts of object-orientation: objects, classes and methods. It gives a solid, hands-on introduction to these concepts without going into the details of Java syntax. Initially Pseudo-codes have been used to make clear the foundation concepts taking a real-life example on bank transaction. A reader can have a first look at several Java source codes from this chapter. Those source codes can be used by the students/beginners for hands on practice to start with.

Chapter 2—Class as the Basis of all Computation opens up class definitions with encapsulated data and function members. Objects are instances of a class (an abstraction which can be regarded as a User Defined Data Type). Use of different primitive data types and operations allowed on them by the java language are also discussed here citing a good number of programming examples.

Chapter 3 – Constructors needed to construct objects from a defined class have been discussed here in details. Examples of default constructor, constructors with arguments, default initialization, constructor overloading, etc are also discussed and explained using examples.

In Chapter 4 -- Functions as a way to define operations/methods have been explained. Differences between pure and impure functions have been illustrated here. Importance of function’s return type, arguments, overloading, etc have been explained. Difference between function prototype and function signature has been

Page 17: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

demonstrated.

Chapter 5 – Class as a User Defined Type tells the readers how one can regard a class as user defined (composite) data type so far as OO programming is concerned. Importance of wrapper classes for primitive data types have also been discussed here showing suitable examples.

Chapter 6 --- Decision Making chapter deals with the conditional decision making constructs like if-then, if-then-else, switch, etc and their applications in program control. The special ?: operator is also introduced here.

Chapter 7 --- Iterations chapter shows how to use for loop for a fixed number of iterations, while loop or do-while loop for any unknown number of iterations. When to use continue & break statements and how to use nested loops are also discussed. It is also illustrated how one kind of loop can be converted into another kind, if required.

Chapters 8 – Using Library Classes chapter deals with simple Input/Output operations taking help of the library classes lying stored in java libraries. Importance of library classes and their use in a java program have been shown. The use and importance of String class is discussed thoroughly.

Chapter 9 --- Encapsulation, Data Hiding and Inheritance chapter deals with the private, public scope and visibility rules. Scope of different variables like instance variables, argument variables, local variables, etc have been discussed with appropriate examples. Package level access control mechanism has also been explained. The concept of single and multi-level inheritance has just been introduced here. The importance of java’s interface has also been explained.

Chapter 10 – Arrays chapter first explains the importance of manipulation of arrays and shows how to create them. The sorting and searching algorithms are introduced and explained. The class Object is also introduced here.

Chapter 11 -- Operations on Files chapter starts explaining the difference between byte and character streams. Examples of both byte-oriented and character-oriented I/O operations have been shown. You can study here how files are created and file operations are performed. Importance of the String and Stream Tokenizer classes is explained with appropriate examples.

For those who are experienced programmers, two more chapters have been added with some advanced topics.

Page 18: JChap_0 About Java, JDK & BlueJ (Prof. Ananda M Ghosh.)

Chapter 12 is concerned with On Applets & Windows programming with AWT and Swing

and

Chapter 13 deals with Object Oriented Analysis & Design using UML.

0.12 Conclusion

This introductory chapter gives a bird’s eye view of the java’s history of evolution and the importance of BlueJ as an integrated development environment for the beginners. The importance of java in this age of internet and mobile computing has been clearly spelt out. Thorough study of the Chapters [1 .... 11] will be essentially required for those who are studying Java for the first time. Last two chapters are meant for advanced learners only.

In this chapter some text portions have been marked within “........” to indicate that those portions have been quoted directly from the official BlueJ site. Please allow me to thankfully acknowledge the BlueJ open sources. The BlueJ screen shots have been included here and will be used whereever necessary.

Let me acknowledge, with thanks, the support and encouragement received from one my ex-students, Dr. Ashok Banerjee.