[Previous]
Into Java, Part II - Online Manual - by Simon Gronlund
[Next]
OS/2 e-Zine!

Go to a Printer Friendly version of this page



Lash Back! - Join in the ongoing public discussion with our interactive forum. Be frank, be vicious, you can even be anonymous.

- or -

Blast Back! Send a private message directly to Simon Gronlund with your thoughts:

Contact OS/2 e-Zine!

Sponsored links:

Summary: Simon continues his exploration of the Java language... with sample code.

Into Java, Part II - Online Manual

By: Simon Gronlund

The Java environment is chock-full of different classes, methods and possibilities. How to get to know it all? Don't do as I did, my first Java lab work. Last year we were using C in our lab works, so I were used of doing quite a lot of work of my own. If I wished a certain object, I had to implement it myself since not so many classes were predefined.

Now our first lab work was to do a text mode application, holding different objects, like rectangles, squares, polygons, circles and so on. Eagerly I jumped straight into the coding part, the planning and designing phase was quickly rushed through. I think it must have been the transport of joy sipping Java, not decaffeinated. So, I did the tiresome work of implementing things, like an abstract RectangleLike class to inherit from (a very important topic of the next column). Finally it was done.

When I then found out that Rectangle is a Java class already implemented, I didn't laugh too much, I'll say! To my relief I soon found out that I wasn't the only one doing that mistake. But stupidity is only allowed once, isn't it?

Javadoc

If I had bothered using the Javadoc part from the very beginning, a lot of hours could have been saved. Let's save this time right away! Open up a new browser window now. Now you can switch between this OS/2 e-Zine! Java column and that new window as you like.

Please navigate to your Java11 folder. There, find the docs folder, then the api folder. Perhaps you have installed Java 1.1.7 on the C disk, so the path will be C:\Java11\docs\api. Now open the packages.html. For most purposes this is a good starting point, so bookmark it in your browser.

I am not one hundred percent pleased with this IBM documentation. Everything is there, up to 1.1.7, but try for example to load the "index" page. It is a file called AllNames.html, and it's 1,430 kilobyte big. Yes, you were correct, 1.43 MB, and in spite of being on your HD it is still slow to load every now and then. IBM, please make this index file in smaller chunks.

Soon you'll see for yourself why I grunt about this part, but I will explain my feelings right away. Often you have a feeling of what method name to expect, but you would like to check it out. Let's imagine, we are looking for a method that will draw a filled rectangle on the screen. Possibly the method name will be drawRectangle, but we aren't sure, and we don't find this method in the class Rectangle. We will try using the Index. There we click the "D", scrolls and there we are.

After many seconds we have found that the drawing method resides in java.awt.Graphics, that is the class Graphics. But it wasn't drawRectangle we were looking for, since it only draws the outline. A shortcut now is to click the "drawRectangle" and hope that the expected method will reside nearby. Yes! Within the Graphic class, the method above is the one, "fillRect". Consider doing this kind of search a dozen times an hour, with tens of seconds running away waiting for the browser to work every link we use, soon you will get rather tired.

SUN

Better then is the Java docs found at Sun web site then. At http://java.sun.com/docs/ you will find the documentation, on-line docs and zipped docs for download, for both 1.1 and 1.2. The pro's with 1.2 is that it's available with frames, but using 1.2 you have to watch out, stuff not implemented in 1.1, clearly marked 1.2, is there. Chose whichever API you like and download it, unzip it to a new folder of your wish, and please, replace the bookmark with this one. The printing is the same, but it's chunked to handy parts and therewhy much faster. The framed 1.2 docs are really a dream.

How to use it?

There is no standard way to use an API (Application Programming Interface) documentation. You'll have to navigate around to acquaint yourself with it. Soon you'll know the most common classes, but to save yourself pain and thoughts, if you find a class frequently used, then study the documentation of that class deeply. You might find interesting ways and methods to do a lot of tasks. Follow the links around to see how they interact. That is a good way to learn Java quickly.

Mainly the documentation is divided in three categories; the packages, the classes and the methods within a selected class. The Java11/docs/api/API_users_guide.html will give you the basic introduction. I suggest you turn to that page soon and study it.

To sum it up, most time we are going to develop Java app's, we will have a browser open at the same time. I often find myself switching between the code editor and the browser quite a lot. Many times I know what I would like to do, and I know how to do it. I still search the API to see if there is a better way to do it, another method or perhaps to get some other angles of approach.

Of course there are a lot more to know than is written in the API, which for a beginner is too poor. Therefore, never miss an issue of OS/2 e-Zine!

Introduction
Java Theory
Java Lab work
[Previous]
 [Index]
 [Feedback]
 [Next]
Copyright © 1999 - Falcon Networking ISSN 1203-5696
November 1, 1999