Well that first tutorial, installing a JDK, was pretty easy. About the only complicated thing was actually navigating to the right place to get a download link on Suns website. Pretty soon, we can write some actual code and see it working, but there are a couple of things worth doing before that to save us time later on. Sometimes, performing a couple of minor housekeeping actions or simple ‘one time’ setups can really save time, especially when using a command line, like we’re going to.
Opening a command line
Although you might think it’s a bit primitive to actually type commands into a computer, doing so really makes you feel that you’re controlling the machine. When you click on an icon on your desktop, do you really know what’s happening? Most of the time even I don’t, and that’s no bad thing in the majority of cases. Actually typing commands makes you feel like it’s really you in control, and not someone else, who happened to put an icon in front of you to click.
- Go to the Start Menu and find ‘Command Prompt’. If it’s not immediately obvious, it will be in ‘All Programs->Accessories’. The icon is a black square, with a white C:\_ in it on Windows XP. When you’ve found it and clicked on it, you’ll end up with a window that looks like this:

Windows XP Command Line
Now, if you type java -version and press Enter, you’ll get a printout from the Java Virtual Machine program detailing it’s version number and a couple of other things. If this doesn’t happen, then you probably didn’t install the JRE along with the JDK, which isn’t a problem, we’ll fix that in the next step.
Setting the PATH
The java program we invoked just now is needed to run programs written in the Java language. In order to create programs in the Java language, you need to invoke a program called javac, which stands for Java Compiler. If you type javac in the command line (and press enter), Windows will helpfully inform you that it can’t find the program, you’re screwed, sorry. I kid! Actually Windows just doesn’t know where to find it, so we need to tell it. Here’s what you do:
- Open the Windows control panel, usually it’s in the start menu.
- If it says “Pick a Category”, select “Performance and Maintenance” then “System” from the bit at the bottom where it says Pick a Control Panel icon. If you’re in Classic View, just select the “System” icon.
- In the window that opens up, click on the Advanced tab.
- Click on the button labeled “Environment Variables”.
- You’ll notice that there’s an entry in the bottom list called “Path”. This is where windows looks for programs to run on the command line. You don’t want to change this, altering the “System Variables” can be risky, but we can add a “User Variable” of our own.

Environment Settings
Click on the New button in the middle of the window and add a new User Entry called PATH (where it says Variable name). Set the value (Variable value) to C:\jdk1.6.0_12\bin and press the OK button. If you didn’t install the JDK into that path, you need to enter wherever you did install it too, of course.
Finally, you need to close your command line window and open it again. Type javac and press enter. This time, you should get a list of options we won’t worry about for now. Windows should not tell you it can’t find anything! You can also type java -version and see that output too now, if you couldn’t before.
A custom command line
You’ll notice that when you open the command line, it automatically sets the current working directory as your ‘home’ folder, which on Windows is the lovely C:\Documents and Settings\<Username>. In my case, that path name has 2 spaces in it! It’s also not where I want to store any Java programs I might write. I want to put my Java programs in a folder called C:\Java\Programs, and I’m also going to use C:\Java for some other tools later on too. So, type the following simple commands into the command window to create the folders:
- cd C:\ <Enter>
- mkdir Java <Enter>
- cd Java <Enter>
- mkdir Programs <Enter>
Now you want to create a shortcut on the Desktop, that will open the command prompt straight into your Java programs folder.
- Close the current command line by typing exit, or clicking the X button.
- Right click with the mouse on the Desktop and select New->Shortcut
- Type cmd.exe in the box labeled “Type the location of the item”, click Next.
- Enter a meaningful name, like “Java Programs” and click Finish.
- Now right click on the new shortcut and select Properties.
- In the box labeled “Start in:”, that probably has %windir% in it, change %windir% to C:\Java\Programs and click OK.

Command Line Properties
Now you have a handy shortcut on the desktop that will take you to your Java programs folder straight away. Next time, I’ll talk about getting a programmers editor to actually write code with. If you want to try something straight away, try finding a simple Java ‘Hello World’ program on the net, typing it in using Notepad, compiling it and running it.
If none of those terms made any sense, I’ll be carrying on soon.