Object Oriented Programming: Installation Notes for Java/BlueJ/javabook

These notes are for use in conjunction with the CD supplied by McGraw Hill. These notes assume you are familiar with using Windows Explorer (not Internet Explorer). If you lose your hardcopy of these notes, a "soft" copy is available, from a link on the subject web page.

This installation is suitable for all Microsoft "Win 32" operating systems. That is, it is suitablefor Windows 95 or any later Microsoft operating system. This installation is *NOT* suitable for Apple computers!

1. Installing Java (SDK, version 1.3.1)
Load the CD and "point" Explorer at the CD. Go down into the folder called "pc", and again go down into the folder called "sun_jdk". Double Click on j2sdk-1_3_1-win.exe Eventually, a large window will pop up, taking up most of the screen. (Actually, this is analogous to the MainWindow class in the "javabook" package from the textbook author, Wu. This large window will be the backdrop upon which a series of dialog boxes will now appear.) This window will contain a longish message which begins with "Welcome to the Java Development Kit Setup Program". Click on "Next".

A licence agreement will pop up. Don't worry too much! You qualify to use this version of Java. Read the licence agreement, then click on "Yes". (If you don't want to agree to the licence agreement, then click on "No", and start planning to spend a lot of time at UTS working on computers which do have Java and BlueJ.)

The next box that pops up contains a message that begins "Setup will install Java Development Kit in the following folder". Further down the screen (past most of the message) will appear the path to that folder:

C:\jdk1.3.1

We will assume that your hard drive is the "C" drive as it is on most PCs. (If not, then be aware that the rest of these notes make that assumption and you will have to adapt the notes accordingly.)

Click on "Next". (Unless you want to install Java on a drive other than "C", in which case click on "Browse". This is the last time in these notes where special mention will be made for people installing on a drive other than "C".)

From this point on in the installation of Java, if something goes wrong and you need to abort the Java installation, you can start from the beginning again. But before you do, delete the folder "C:\jdk1.3.1".

The next box that pops up contains a message that begins "Select the components you want to install". All the components should already be selected. If that's the case, just click on "Next".

The installer will now go to work. Eventually, a box will pop up with the message "The Java delopment Kit Setup is now complete". Just click on "Finish".

You have successfully installed Java!

2. Installing BlueJ, version 1.1.4
BlueJ is a software tool that helps us write (and run) Java programs, just like Microsoft Word is a software tool that helps us write documents. BlueJ and Java are not the same thing. In common IT slang, BlueJ runs "on top of" Java.

Using Explorer to browse the CD again, go down into the folder called "pc" again, and then find the file called "bluej-114". (By the way, iyo might notice that the type of this file is "Executable JAR file", where "JAR" stands for "Java ARchive. Such "dot jar" files are a common way of storing java programs. BlueJ is actually a program written in Java.) Double click on "bluej-114".

As with the Java installation, we will assume that you are installing onto the "C" drive. A window will pop up with a picture of a "Blue Jay" in it, and the title "BlueJ Installer". (A "Blue Jay" is a North American bird. In the Java community, it is common to attach a J-for-Java to the name of Java related softare products. For example, some of you may have heard of the software tool "JBuilder".)

Unless you are installing on a drive other than "C", check that:

"Directory to install to" is c:\bluej1.1.4

and

"Java (JDK) directory" is c:\jdk1.3.1

If necessary, change the information shown so that Directory to install to" and "Java (JDK) directory" are what is given above. Then click "Install".

When the installation is finished, click "Done".

2.1 Installation Problems with BlueJ
If you have problems installing BlueJ, first check out the BlueJ Frequently Asked Questions (FAQ) web page ...

http://www.bluej.org/help/faq.html

See section 2 "Technical Problems", subsection 1 "Installation Problems". A very common problem on older machines (e.g. Windows 95) will be "Out of Environment Space". There is an FAQ entry for that problem.

If you still can't get things working, talk to the OOP lecturer. BUT BE WARNED! (1) "Talk" means face-to-face. It does not mean email. Any email on BlueJ installation problems will not receive an answer. (2) The lecturer's first question to you will be, "Have you read the FAQ?". In a university environment, we are happy to help you, but only if you demonstrate that you have first tried to help yourself. Its not that we don't want to help, its just there are many students to help, and so we concentrate on helping those students who have tried to help themself.

2.2 Checking the Installation by Running "Shapes"
You should now run BlueJ to check that the installation has worked correctly. To do that, "point" Explorer into C:\bluej1.1.4. You will see a file called "bluej". Right click on it. A window will pop up, and you should select "Open". BlueJ should start up.

You should then be able to open the "Shapes" project, and run it, just as you did in the first lab exercise at University, but with one minor difference. When the various class icons for this project appear ("Square", "Circle", "Triangle") notice the diagonal lines in the bottom half of each icon. These diagonal lines were not present when you ran this project at university. These lines mean that the Java source code (ie human readable code) for this project has been loaded, but that source code has not yet been compiled to produce the machine exeecutable "Java Byte Code". To compile this project, just click on the "Compile" button. The compilation process is not instant. It will take a few seconds. When compilation is completed, you should be able to run "Shapes", and verify that your Java and BlueJ installations have succeeded.

2.3 Runtime Problems with BlueJ
If you had a problem running BlueJ, first check out the BlueJ Frequently Asked Questions (FAQ) web page ...

http://www.bluej.org/help/faq.html

See section 2 "Technical Problems", subsection 2 "Runtime Problems". If that doesn't help, see the lecturer face-to-face.

2.4 Running BlueJ via a short cut icon
(This section is an optional part of the installation, regarding some cosmetic issues in running BlueJ. If you can't perform this part of the installation, you might try asking a fellow student to show you. The lecturer won't be taking the time to show you, since its only a cosmetic issue, and there are more important things for him to talk about with you and other students!)

Right clicking on "bluej" in c:\bluej1.1.4 and selecting "open" is one way that you can start BlueJ in the future.

Another way to start BlueJ is to create a short cut, if you know how. After dragging the short cut icon to the desktop, right click on the icon, select "properties", and go to the "Program" tab. In the "Run" field, select "Minimized" and then "OK". This small (and not terribly important) change will mean that the MS-DOS window associated with BlueJ will not appear on the screen, but merely as a minimized icon on the toolbar.

If you have created a "short cut" icon, it will appear as a generic "MSDOS" logo followed by "Shortcut to bluej". That's a workable icon, but not a very pretty icon. You can change to appearance of the icon to the BlueJ "bird" icon, as follows. Right click on the icon and select "properties" again. Go to the "Program" tab, and select "Change Icon". Another window will pop up. Select "Browse" and select the file "C:\bluej1.1.4\lib\bluej.ico". Hit open, then "OK". the window will disappear, and you should then select "OK" on the main "Shortcut to bluej Properties" window. After a moment, the icon should change to show the "bird" picture.

3. Installing "javabook"
The "javabook" is not part of standard Java or BlueJ. It is a set if "library" classes supplied by Thomas Wu, the author of your textbook. In many java programs given in Wu's book, there is a line of code thus:

import javabook.*;

This line tells the java compiler to bring into that program ALL the classes available in the "javabook" library. (That's what the asterisk means, "all".) So, if you are going to run, on your home PC, any program from Wu that contains that "import" line, you will need to load Wu's "javabook" class library onto your PC.

The current CD does not have "javabook" on it. Instead, you need to download it from the McGraw-Hill web site for Wu's book ... http://www.mhhe.com/engcs/compsci/wu2/student/olc/classes.mhtml In the table on that web page, on the second row, immediately below "To download click the link below...", you will see a hyperlink "javabook". Left click on that link and save it to C:\bluej1.1.4

Make sure that the copied "javabook" folder on your C drive starts with the lower case letter "j", not the upper case "J".

3.1 Editing bluej to change the "Classpath" variable
When the Java compiler encounters an "import" statement, from where on your computer does it import the files? The Java system searches the "class path". The class path is a series of folders. The Java system looks in the first folder, then the second, and so on until it either (1) finds the class that it has been asked to import, or (2) exhausts all the folders listed on the class path.

The classpath information is specified to the Java system in the "bluej" file. Using Explorer, right click on "bluej" and select "Edit" (NOT "Open"). A Notepad window will pop up, showing you the contents of "bluej". (These note assume you know how to edit and save in Notepad.)

3.1.1 First Change: Changing the Application Base
On about the third line of "bluej", you will see a line that BEGINS ...

set APPBASE=

If the complete line is NOT ...

set APPBASE=c:\bluej1.1.4

Then change that line so it does. This line is saying "Every time you see APPBASE in the rest of this file, surrounded by percentage signs, substitute for it C:\\bluej1.1.4". The word "APPBASE" is short for "Application Base". BlueJ is our application program. All files associated with BlueJ are stored in its base folder.

3.1.2 Second Change: Adding %APPBASE%\javabook to the Class Path
In "bluej", you will find the line that specifies the classpath. Its the line beginning ...

set CLASSPATH=%APPBASE%\lib\bluej.jar;%APPBASE%\lib\antlr.jar

Let's take a closer look at the part after the "=" sign and before the semicolon ";" ...

%APPBASE%\lib\bluej.jar

You've already been told that "%APPBASE%" should be substituted, to give ...

C:\\bluej1.1.4\lib\bluej.jar

This is the first file of the class path. That is, its the first place where the java system will look for any files that need to be imported. (The "jar" stands for "Java Archive File".)

Now look at what's between the first and second semicolon ...

%APPBASE%\lib\antlr.jar

Once again, substituting for %APPBASE" gives ...

C:\\bluej1.1.4\lib\antlr.jar

That's the second place where the java system will look for any files that need to be imported. There are more files on the classpath, but you get the idea.

Now, here's the change. Immediately after the "=", insert the following ...

%APPBASE%;

Don't forget the semicolon! The modified line now commences ...

set CLASSPATH=%APPBASE%;%APPBASE%\lib\bluej.jar;%APPBASE%\lib\antlr.jar

We are now telling the Java system to first look in the application base "C:\\bluej1.1.4" before it looks anywhere else. That is the place to where we copied "javabook" off the CD.

If you are running BlueJ while you make this change, you will need to restart BlueJ before this change to the class path wil take effect.

3.1.3 Verifying the Changes
Now do the "FunTime" and "DisplayMessage" exercises from your first set of lab notes. If these exercises compile and run correctly, then your installation of "javabook" is working.

If you cannot make javabook work, then naturally talk to your lecturer. But remember, "talk" means face-to-face, not email. Email on installation problems will be ignored. Also, be very clear that it is javabook that is causing problems. Don't wait to be asked "Did you get the Shapes exercise working?" Start by saying to the lecturer, "I got Shapes working, but I have a problem with javabook, because I can't get FunTime to work." This may seem silly, until you remember that you are probably the 50th person to speak to the lecturer about an installation problem.

The best way to get help from the lecturer with fixing up your javabook installation will be to print off a copy of "bluej" and show that to the lecturer. Until he has seen that, there is not much he can do to help.