Setting up Java on your system

A Step By Step Guide

Setting up Java can be a frustrating experience, especially because computers don’t always behave the way you would like them to. That is why I have provided these step-by-step instructions for setting up Java on your system. Currently, the Java SDK is supported on Windows, Linux, and Solaris. Note to Mac Users: Sun Microsystem’s Java SDK only supports the above Operating Systems. However, Apple has released their own Java Development Environment. Please follow the directions marked “Mac Users” only!

If you are confused about any of these steps, please feel free to contact me either by email or we can discuss it during our sessions.

Step 1: Downloading Java SDK

First Download A Copy Of The Latest Java Release

When you get to the Java web site (java.sun.com), you might see many different download links. Only follow the one that takes you to the Java 2 Standard Edition (J2SE) SDK. Good news, this one download package will include all the components of Java you will need to perform in this course, as well as ICS 22 and ICS 23. It is best to download the most STABLE package.

  • Go to the Java web site.
  • Locate downloads on the menu and click on Java SE. They will offer many packages of the Java 2 Platform, Second Edition. Click on the one that says “JDK 5.0 Update 9″. If you prefer to use NetBeans, click on the one that says “JDK 5.0 Update 9 with NetBeans 5.
  • At the download page, select the most current stable SDK version that’s available for your operating system.
  • After clicking on the download button, follow the on-screen instructions. You must accept the License Agreement.
  • Save the setup file to your hard disk. On a 56K modem, it takes about 2 hours to download this file.
  • Run the setup file and follow the on-screen instructions. I advise you to keep the default values the same for the installation directories, unless of course there is a hard disk space issue.

Mac Users

  • Go to Apple’s Java Developer web site. (http://developer.apple.com/java/)
  • Click on the Java Downloads link on the right-hand side.
  • At this page, you will see a large list of Java downloads. Don’t get confused. If you have an Intel-based Macintosh computer, select “J2SE 5.0 Release 4 (Intel)”. If you have a PowerPC-based computer, select “J2SE 5.0 Release (PPC)”.
  • You will be transfered to the download page. Click on the link in the right hand box, it will say the size of the file, ie “80 MB”.
  • Run the setup file and it should complete the installation automatically, as well as set up all the environmental variables.

Step 2: Downloading a IDE

Choose the Right Development Environment For You

In order to write java code, you will need a text editor. There are many available on the internet, some for a minimal fee and some for free. You may use any of the following.

  • Notepad - This is free and included with Windows; however, since there is no syntax coloring and highlighting, it makes it difficult for beginners.
  • TextPad - This is the program we use in the ICS labs, so you will be more familiar with it after your lab course. It does, however, require a small registration fee. This program can be downloaded at www.textpad.com.
  • Eclipse - This is a slightly more heavy-duty IDE and is often considered one of the best programs for coding Java programs. However, I personally feel that this program comes with too many gadgets and gizmos for the beginner. Nonetheless, if you would like to use this program, it is free and can be downloaded at www.eclipse.org.
  • Crimson Editor - This is a program that was introduced to me by a friend of mine. It is probably my personal favorite because it is light, compact, easy-to-use, and best of all it is free. It is sort of a cross between TextPad and Notepad, but it includes syntax coloring and support for many different languages including C, Java, HTML, PHP, etc. This program can be downloaded at www.crimsoneditor.com.

Step 3: Configuring Windows for Java

PATH and CLASSPATH Environmental Variables

In order to compile or run Java programs from anywhere in your Windows operating system, you will need to teach Windows how to find its location. This information is stored in an environmental variable called PATH. PATH is a list of locations on your hard disk, separated by semicolons, that tell Windows where to look whenever the user tries to run a program.

We will be modifying the PATH and CLASSPATH environmental variables on your system. I know this might seem a bit confusing, but try to do exactly as I say. If you have any problems, go back and try this again. Otherwise, please feel free to ask me. Now, how we modify these variables depends on what operating system you’re using:

Windows 95, 98, and ME

  • Open the file C:\AUTOEXEC.BAT.
  • Add the following two lines to the end of the file, where “C:\j2sdk1.5.0_09\” would be replaced by your installation directory:

    set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_09\bin

    set CLASSPATH=%CLASSPATH%;.;C:\Program Files\Java\jdk1.5.0_09\lib

  • Once this is done, save the file and restart your computer.

Windows 2000 and XP

  • Right-click on the My Computer icon found on your desktop. Select Properties. Select the Advanced tab. You will see an Environmental Variables button. Click on that. Under the “System Variables” tab, find the PATH variable. There will most likely already be some information already written in there, scroll to the end of it and append this text:

    ;C:\Program Files\Java\jdk1.5.0_09\bin

  • Following that, select the CLASSPATH variable. Chances are, if you haven’t had Java installed on this machine before, it won’t be there. It’s okay. No need to panic. Click on the ‘New’ button and type CLASSPATH as the name of the variable, and this following as its value:

    .;C:\Program Files\Java\jdk1.5.0_09\lib

  • Remember, you must replace “C:\Program Files\Java\jdk1.5.0_09\” with the directory of your Java installation
  • Once this is done, save the file and restart your computer.

Step 4: You’re all done!

Check to make sure Java is installed properly

Once you’ve restarted your computer, it’s time to check to make sure Java is working properly.

Open a Command Prompt window:

  • Click Start. Choose Run.
  • Type in ‘cmd’. Hit enter.

In command prompt, type the following:

java -version

It should return something similar to this:

java version “1.5.0_09″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b09)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

If it does, congratulations, you’ve successfully installed Java on your computer! Now get coding!