Since 1995, when Microsoft replaced the old 16 bit Win3x with it's 32 bit operating systems, WinNT and Win9x onwards, Windows users have not really had to think about defining paths as environment variables, unless they have had the misfortune still to be running a 16 bit application from the command prompt. So when lessons in the Java Tutorial make references to setting path variables, I feel as if I have been time warped back 15 years.
The subject of my last blog talks about setting the class path, and the "Hello World" for Windows lesson in the very first trail obliquely embeds instructions about path settings. And when I say oblique, I mean very oblique. First they set you up to hit an error. Then they provide a link to a troubleshooting page. And from there there is another link to instructions on writing a path to javac in the user environment settings. Considering the level of detail given on simpleton tasks, like saving a text file, or basic navigation at the command prompt, and considering that this is supposed to be a really easy lesson, intended to make people like Java, not hate it already, the instructions on the javac path are very badly written.
And it's not just me. I keep a vague eye on the Java Tutorial Discussion Group. Here is an example of someone else who had trouble with the path settings. The only third party response in this thread was singularly unhelpful, so before proceeding my journey through the Java tutorial I shall revisit the early instructions on path settings.
The "Hello World" for Windows lesson is both irritatingly simplistic and condescending in some ways, and incomplete in others. For example in the section on creating a source file it gives the option of downloading the source file or typing the code in longhand. Why doesn't it mention the option of copying and pasting? In the instruction on saving the source file it addresses users as they have never saved a file from a Windows App, but it gives no guidance on the file location strategy. It assumes the user has already created a folder for their source files, and it breaks with Microsoft advice not to put user/application stuff in the root directory of the system drive. And to compound the confusion, having suggested putting source files into C:\Java, a couple of paragraphs later the user is taken to D:\Java.
And then without a whisper about path settings the lesson says (quote):
Now you are ready to compile. At the prompt, type the following command and press Enter.
The compiler has generated a bytecode file,
All of which is regrettably not true. The system has in fact generated an error message:
'javac' is not recognized as an internal or external command, operable program or batch file
The pitiful excuse for omitting to say anything about path settings in the lesson might be that the release notes include an optional instruction to update the path variable after installing the JDK. So on the one hand the user is assumed to such an idiot that they need screen shots to help them save a text file or run the dir command, while on the other they are assumed to be sufficiently expert to read the release note in intimate detail and to complete even the optional instruction in advance.
I have mentioned before that I am working on an old and slightly cranky computer, so that setting the path as an environment variable didn't work for me doesn't necessarily mean the instructions are wrong. But it does indicate that doing so is not 100% reliable. So to assume in the lesson that the variable has been set, and that it will work is a bad writing strategy.
In my early blog, I suggested that a possible cheat would be to copy the source file into the
jdk6\bin\ folder and run javac from there. But after filling what is supposed to be a system folder with my own rubbish, I accept that this is perhaps not the neatest strategy. Instead I recommend putting a short batch file in the Windows home directory. You can use this both to navigate to wherever you keep you keep your java working files and to set a temporary path to the
jdk6\bin\ folder. This path will stay current as long as the command window remains open.
My batch file is called cd1.bat and it contains just 2 lines:
cd My Documents\Current\Java
set path=C:\Program Files\Java\jdk1.6.0_03\bin
So now I can keep all my java working and experimental files in a logical place and compile source code without hassle. To get there I just enter cd1 at the opening command prompt.
And I contend that instructions along these lines would improve the "Hello World" for Windows lesson.