The purpose of this document is to familiarize the user with our lab setup. We will be using a cluster of Windows NT workstations, and writing Java applications with the assistance of Microsoft Visual J++, a professional software product. This and many other supplementary products are not completely necessary to write Java programs*, but their use greatly enhances speed, productivity and the learning process.
This handout is designed for users who may have had only minimal exposure to Windows operating systems and integrated development environments; but will also be of use to users familiar with Windows NT and Visual J++, who need to know the particulars of our setup.
*Indeed, all one really needs is the JDK 1.1 from Javasoft and an ascii text editor such as emacs (Unix) or edit (MSDOS). However, as your projects increase in complexity, so will your need for the appropriate tools.
A learned software consultant was once approached by a bedraggled pilgrim who had not showered in many days.
"O wise one, I am troubled. I must continually master new languages, operating systems, and applications in order to remain competitive, and I must remember so many commands and keystrokes and directories where everything is supposed to be kept, that I cannot write a line of code without devoting months of effort and frustration. Yet you have mastered all these with ease, and even find spare time to go to the beach and see movies. How may I discover this programmer-nature, that I as well may become sought after in business and academia and still have a social life?"
The consultant responded by lifting his index finger.
The pilgrim went away, perplexed.
Several weeks later, the pilgrim returned with bloodshot eyes, wearing black wrist guards.
"O wise one, woe is me! For I have reflected much upon your answer, and concluded that the only answer was to become a touch typist so that I could write code faster. I mastered the Dvorak keyboard and can now type at 80 words per minute, but now I have Repetitive Strain Injury and must wear these wrist guards and the pain is most bothersome! Clearly you must be mistaken when you lift your finger."
The consultant responded by depressing his index finger.
The pilgrim went away, more confused than ever.
Several months later the pilgrim returned, this time pale and near death.
"O wise one, I believe that you do not know the answer. For your depressed finger suggests a bowed head, so I have pursued the ascetic life by fasting, meditating, and practising yoga. I am much more spiritually complete, but I still find it overwhelming to sit down and write a line of code. Clarity of thought and purity of the soul is not the answer; you have misled me. I believe I know what this programmer-nature is: it is merely the ability to speed-read computer manuals together with a photographic memory. It is the only explanation for your success."
The consultant was silent for a moment, and then responded by lifting, and then depressing, his index finger.
At this the pilgrim was enlightened.
A note from the course assistants: Help was only a mouse-click away. The Integrated Development Environment (IDE), though still not a cure-all, can alleviate many of the pilgrim's complaints and make programming a more enjoyable experience.
An IDE does this by integrating all the necessary functions into a single, easy-to-use graphical user interface. We will be using Visual J++ 6.0, an IDE developed by Microsoft, which supports Java 1.1. Many other commerical IDEs are available, sporting numerous features and gadgets to ease the programmer's way. At the end of this handout we will describe some alternative IDEs and some issues you should consider in selecting an IDE for your own use.
When you first come in to lab, be sure that the machine you sit down at is a Windows NT workstation, and not one of the Hewlett-PackardApollo's, which are for a different class. (The NT's look cooler.) If you see a screensaver, you can jiggle the mouse or hit a key to get the machine's attention. Be sure to avoid any machines labeled NOT WORKING.
You will probably see the message "Press Ctrl-Alt-Delete to log on." This means to simultaneously hold down the CTRL, ALT, and DEL keys. If you are used to other Windows operating systems, you might expect this to reset the machine, but in Windows NT, this will start the login sequence.
You will be prompted for a username and password; ask a course assistant where to find them.
To get a Command Prompt (a command line interface that resembles MS-DOS), you will have to use the Start menu. Find the button in the lower left corner of the screen labeled "Start". Single-click on it. A menu will appear with several choices. Move the mouse pointer over "Programs". A moment later, another menu will appear. Move the mouse pointer over "Command Prompt". A single-click will start up the program. Later in this document and in other handouts, we will use the following convention to describe the process of wading through menus:
Menu Name > First Menu Selection > ... > Last Menu Selection
For the command prompt, the shorthand would be:
Start > Programs > Command Prompt
Sound reasonable? Now we'll try some window exercises.
If you have not called up the Command Prompt, do so now. Look at the gray bar at the bottom of the screen (called the Taskbar). Notice how a button has been added to the Taskbar that corresponds to the Command Prompt. The button will be depressed for every window that is open and raised for every window that is minimized.
To get a feel for this, minimize the Command Prompt by clicking on the small gray button labeled with an underbar ("_") in the upper right corner of the Command Prompt window. Notice how it shrivels up, and the button on the Taskbar pops out. Click on this button that just popped out. The window should re-inflate.
Windows can also be maximized. Just click on the gray button in the upper right corner that contains a black square. The window should expand to its maximum size, and the button should look different now (it will contain multiple black squares). Click on this same button and the window will return to normal.
Finally, the window can be closed. Click on the gray button containing a black X. The Command Prompt, and its corresponding button on the Taskbar, will disappear forever. Now start up another Command Prompt.
You can browse directories in two basic ways: either use the Command Prompt, or use Windows NT Explorer. In the Command Prompt, you can list a directory by typing
on the command line, and hitting return. (You always have to hit return after a command.) You can move into a directory by typing
where <name-of-directory> is the directory you wish to change into. This should appear to be very similar to MS-DOS. Other pertinent commands include del (delete), ren (rename), and copy, as well as type which will blast the text across the screen. If the file is long, you can display a screen at a time by entering
type <filename> | more
where <filename> is the file you're interested in, and the funny symbol (" | ") is the vertical bar (also called "pipe"). more is a simple program: hit any key to advance to the next screen of information. You can also have the output of other commands "pipe" their information to more, such as
dir | more
Piping information between programs is a simple and powerful way to get things done. If you've been using UNIX for a while, you probably found several uses of this concept. Later in the course, you will be writing programs that pipe information to each other, under a slightly different name: streams.
If you'd prefer to exercise your mouse hand instead, you can use a graphical user interface by selecting Start > Programs > Windows NT Explorer. You will see two panels. On the left is the directory structure. On the right is a listing of all the directories and files contained in the current directory. In either panel, you can select a directory or file by single-clicking on it, and switch into a directory (or view a text file, or run an application) by double-clicking on it.
Moving a file or directory is just a matter of drag-and-drop. You can also cut, paste, copy, rename or delete files or directories using the File and Edit tabs. For more advanced features and information about Windows NT, select Start > Help > How To...
Please help us out by setting up your own homedir. This should be easy; simply open up Windows NT Explorer and create a directory with your typical username in the U:\675s directory. Now go to S:\projects and copy the entire directory structure into your new homedir. You will find these two drives handy: the U: drive contains all the user homedirs for the class, and the S: drive is where the problem set code will reside.
When it comes time to log out, be very careful. Windows NT is very fussy about this. The proper way is to select Start > Shut Down. When given the choice to Close All Programs and Log On As Another User, click on Yes. This is the only valid choice for our laboratory cluster.
The screen should clear, and the login screen should pop up for the next user.
To start up the application, you can click on the Windows NT Start button (lower left corner of the screen) to select Start > Programs > Visual J++ 6.0 > Visual J++ 6.0.
After the startup sequence, you should see the central code editing window, with lots of subpanels and brightly colored buttons. If you like guessing games, you can try to figure out what the button icons mean. Otherwise, you may rest the mouse pointer over a button for several seconds. A "tooltip" will pop up describing what the button does. All of these functions can also be found somewhere in the Visual J++ menu system.
There is another window, which you will be using often. This is the Project Explorer window. You can call it up by selecting View > Project Explorer. This displays all of the files which you may currently work on, organized into ``solutions'' and ``projects.'' Each of you will have one solution which will contain several projects over the course of this class. It should be automatically loaded up by Visual J++ when you start it up.
Also of use is the Class Outline. You can call it up by selecting View > Other Windows > Document Outline. This breaks down Java classes into their component parts and, if appropriate, displays the Java documentation for that part of the code. Browse around in the provided code in this window and you will see how this works.
Finally, the Task List will be of great use when you begin writing code. If it is not onscreen already, call it up using View > Other Windows > Task List. As you write Java code, Visual J++ will compile your code on the fly and indicate any errors in the task list. This should keep you aware of glaring bugs and encourages incremental design techniques.
All these windows are dockable. This means that you can drag the window around the screen, and it will attempt to ``dock'' with the nearest window, giving you the freedom to set up the layout as you like. Once it is docked, a window can be undocked by double clicking on the dark blue titlebar. (Similarly, to re-dock.) Some windows, like the Document Outline and Project Explorer, like to combine into one window with several tabs. These can be undocked by double clicking on their tab instead.
Several preset window layouts are available. There is a menu on the far right end of the toolbar. Feel free to use these as is, or use them to create a layout of your own.
Go ahead and add a class to the Calculator project. You can do this by selecting Calculator in the Project Explorer, right clicking on it, and selecting Set As Startup Project. Now try Project > Add Class, and select Class > Class from the New tab. You may give this class any name you like.
Notice how different bits of code are colored differently. This is meant to aid the programmer in visualizing the syntax of Java statements.
The typical operations can be performed in the editing panel: cutting, pasting, searching, replacing. (See the Edit tab.)
Now, you're ready to do your first compilation. Select Build > Build. This will take a few moments to compile your java file. It should compile properly. (If it doesn't, please ask a course assistant for help!)
Now, you want to look at your exciting new application. Select Debug > Run. This will create a new window, theoretically, with your cool new program in them.
Whenever your Java program prints information using System.out.println(), that information is captured by the console. If you have used the JDK (Java Development Kit), which contains command-line tools for compiling (javac) and running (java), then the console is simply the window you type your commands into. (This applies to both our NT cluster and Athena, and anywhere else you use the JDK.)
In Visual J++, the information your programs spits out is captured by a special application, JVIEW. When you run your program using Debug > Start, the JVIEW window will pop up and deal with any console input or output. Note that you must enable this application explicitly by going to Project > Options > Launch. Click on Custom and change the Program field to read JVIEW.EXE instead of WJVIEW.EXE. Also, note the Arguments field. The last argument should be the name of your main class. In the case of Calculator, this will be Calculator.Main. After the main class is where you will append your command-line arguments that will be read by the main() method of the main class.
You should to comment out a portion of the code, in order to see what kinds of compiling errors you can get. Commenting means to mark off an area in your code file that will be deliberately ignored by the compiler. In java, you use the following scheme to comment your code: (here, the words "This is a comment." will be ignored by the compiler: (note that in the second case, only the remaining text on the same line is ignored)
/* This is a comment. */
// This is also a comment.
* a comment.
Printing is a piece of cake. To print your code, be sure the window containing your code has a blinking cursor (click in the window if it does not), and then select File > Print.
You may get a message about an uninstalled printer. If so, please ask a course assitant for help.
To print help documentation (see below), be sure the page you want appears in the right hand panel, and select File > Print in the Visual J++ Documentation window. It will prompt you as to how much you want to print; please select Print the Current Page.
If you have a burning reference-type question that can be answered by the Java 1.1 API (Application Programming Interface) or the Java Language Specification, these can be found online. Select Help > Contents. A window should appear named ``Visual J++ Documentation.'' Notice that there are four tabs: Contents (which should be selected), Index, Search, and Favorites. In the panel on the left, you will see a directory tree with a single entry. You can navigate this tree by double-clicking on the book icon(s). Reference material can be found by selecting Visual J++ Technology Preview 1 > Reference. In the panel to the right, you should see a hypertext document with navigable links. You will probably want to go to Java API most of the time. It often has details that the book Java in a Nutshell did not have room to print. Another handy link is the Java Language Specification. This is the definitive text on the Java language and a rather hefty read.
More general help is available. Feel free to navigate the documentation (the tree structure in the left hand panel should help). Since there is a lot of material here, you can either expand a directory by clicking on the plus symbol, or contract a directory by clicking on the minus symbol.
There are many features to explore, and fortunately, Microsoft has online documentation that should help you acclimate. The following sections are helpful to the beginner:
Beware any documentation referring to the Windows Foundation Classes (WFC), J/Direct, COM, ActiveX, the SDK, or any other non-portable Microsoft technology. We will not be using these technologies in this course. The same goes for HTML forms, applets, or database components. This class will focus exclusively on standalone console applications, written in 100% pure Java.
There is also a help index and search engine of the usual (only vaguely helpful) variety.
Of course, whenever you're in lab, there should be course assistants there to help you. If you need to report bugs, or simply want advice on how to proceed, feel free to talk to them.
The course assistants are there to help; ask questions early and often! :o)
Criteria you may want to use in selecting an IDE:
Beware of any piece of software with alpha, beta, pre-release, preview, or any version number less than one. Also keep in mind that just because the version number of the product is 1.1, you cannot assume that it supports the Java 1.1.
1.0 - Popular support in commercial browsers.
1.1 - Some changes to the language spec. Stable. Popular in enterprise computing.
1.2 - In beta at the time of this writing. Many new advanced features. Little or no change to the language spec.
Identify all the platforms you need this product to run on. You may have to dig deep into the technical specifications for their product to be absolutely sure that your configuration is supported.
IDEs that support enterprise computing are at one extreme end of the spectrum, and homebrew solutions are at the other end. Sometimes trial downloads of the product are helpful.
Some things you need to know about:
If you need an IDE that can handle multiple computer languages, edit JavaBeans, includes database connectivity...
This course is a part of Lynn Andrea Stein's Rethinking CS101 project at the MIT AI Lab and the Department of Electrical Engineering and Computer Science at the Massachusetts Institute of Technology.
Last modified: Thu Jul 10 13:01:20 1997