The Command Prompt

  Every O/S has a command prompt interface but in order to use it for Java we need to set two environment variables: path (to inform the O/S where the JDK binaries reside) and classpath (to inform the Java VM where our classes reside). Once these two are set, you can issue any of the following commands:

cd \prog Makes \prog the current working directory
javac Compiles your program
java Prog Runs your Prog.class program
java eCheck nnn     eCheck exercise nnn, i.e. the app
java Options Allows you to set your eCheck options, e.g. login data.

We will only discuss setting the environment variables on Windows because doing so in any other O/S is similar if not easier. The Start, Accessories sequence allows you to launch the Command (or MS-DOS) Prompt. The black screen is characterized by its > prompt. In order to compile/run Java programs, we must first issue the following two environment commands:

   >set classpath=.
   >set path=\Program Files\java\jdkxxx\bin;%path%
(there should be no spaces before or after the = sign). These two commands must be issued every time you launch the command prompt console. If you find this inconvenient, you can use the procedure described below to change these two environment variables permanently.

Setting the Java Environment Variables in Windows

You must set the path variable so it points to your JDK before you can issue Java. This can be achieved in two different ways. The first is easier but requires that you issue a command every time you open the command prompt window. The second is a bit more involved but it sets the path once and for all. Choose one of the two:

- Using the "begin" Command

First, determine where your JDK is located. On most machines, it will be in \Program Files\Java\jdkxxx\bin;, where xxx is the JDK version, e.g. 1.6.0_02. Second, edit the file begin.bat stored in your Working Directory and change its second line so that it correctly points to your JDK, e.g.
  set path=\"program files"\java\jdk1.6.0_02\bin;%path%
Save the modified file. Now every time you open the command prompt you will need to issue the command begin, and this will correctly set your environment.

- Using your O/S

In order to avoid having to manually set the environment variables path and classpath every time the console is opened, you can set them once and for all within Windows as follows:
  • For the Windows NT/2000/XP/Vista line: These variables can be set by going to the Control Panel, selecting System, and then locating the environment variables section in the Advanced tab. Note that Windows XP recognizes two types of environment variables: User (in the upper pane) and System (in the lower one). Make sure you use the lower pane in the following:

    • Add a new variable with name: classpath and value: . (a period).
    • Note that there is already a variable named PATH. Highlight it and click Edit. Modify the shown value by inserting the following string at its beginning:
      \Program Files\Java\jdkxxx\bin;
      (where xxx is the JDK version, e.g. 1.5.0_02). In other words, the new value must start with the above string and continue (after hte semicolon) with whatever the old value was.

  • For the Windows 95/98/Me line: These variables are set in autoexec.bat, a file in the root directory (\)of your hard disk. Edit this file and add to the two lines:
            set classpath=.
            set path=\Program Files\java\jdkxxx\bin;%path%
Note: you can configure the command prompt console in Windows-XP by clicking the icon in its upper left corner. For example, you can increase its scrolling buffer, modify its font, or enable mouse-ENTER copy and paste.