01 – System Setup
Like all great endeavors, learning to code in Java (or any language) takes time, effort, lots of work, probably a little swearing, and preparation. Everybody loves to jump right in and start coding, but let’s get you set up with some basic tools before we start anything else.
In order to complete the exercises contained in this document, you will need to have installed some version of the Java Development Kit (JDK) and some editor to work with the code you create. First let us download and install the JDK.
Open a web browser to the Java homepage. You’ll want to go to the “Java SE Downloads” link and download a suitable version for your platform. Try to get the newest version and make sure it contains at least the Java Development Kit (JDK). Some have extra stuff like NetBeans, which is OK, and eventually you may want to learn, but we’re going to avoid a complex IDE like NetBeans or Eclipse in the early stages of the tutorial. As of this writing the most current version is 6 update 2. I do a lot of development in version 5 still, and really just about any version of 1.4.2 or newer will work for our purposes. It’s a good idea to try and stay as current as possible. Just make sure when you download that you get the JDK and not just the runtime environment (JRE). Note that if you use OS X (10.3 or 10.4 is recommended) you already have some suitable JDKs installed and you won’t be able to get them for the Mac on the Java website.
After a reboot (on some operating systems) we need to test your system path environment. Open a terminal or command prompt and try the following two commands:
If either of these do not work you will need to modify your environment to include the Java binaries in your path. This varies greatly by system, so it’s a little hard for me to include details here (see the footnotes for some possibly helpful explanations for Windows). It may also be worthwhile to run the first command again with a “-version” option to make sure the version you are running is the version you think you installed.
Next we need to install an editor that’s appropriate for working with Java files. At the moment I recommend that you stay away from an integrated development environment (IDE) like Eclipse or NetBeans because they hide much of the environment from you, thus making it harder to learn about the workings of Java.
An appropriate editor for starting to learn Java is the free and opensource JEdit text editor. Open a web browser to the JEdit web site. From there select the download link and download an appropriate installer for the latest version (4.3pre10 is what I recommend as of this writing). Run the installer and accept the default options.
With these steps complete you are ready to take the next steps into learning Java. I wish I could say that with the next installment you’ll be writing programs that you’ll be able to execute and run, but we do have to cover some rudimentary steps first. Have patience with me, and I think you’ll learn this stuff in a way that will have you understanding it better than just running in and trying to do it.
On windows, to add the Java binary path to your system environment try the following steps. Open your control panel and select the icon for system properties. Switch to the advanced tab and click the â€œEnvironment Variablesâ€ button at the bottom. Add a user variable named Path and assign to it a value that matches the path to your javac executable. With version 1.4.2 it is likely in a directory called C:\j2sdk1.4.2_XX\bin or with version 5.0 it is likely in a directory called C:\Program Files\java\jdk1.5.0_XX\bin where XX is the release number – check your filesystem. In either case locate the javac executable and add its directory to your path.