CSC 104: The Why and How of Computing
Date: June 25


The following is a simple step by step instruction on how to create and run your own JAVA program. Everything you need is available in CDF PC Lab.
  1. Open Notepad

    Go to Start -> All Programs -> Accessories -> Notepad as shown in the following figure and click on Notepad to launch the program.


    Figure 1: Launching Notepad in Windows.

  2. Type the JAVA code in Notepad


    Figure 2: Typing JAVA code in Notepad.

  3. Save the code as JAVA file

    To save the file as a JAVA program, you need to save it with the extension .java
    To change that, in the Save as Type box (the highlighted area in figure 3), select All Files.
    Then, provide the file name (example.htm in figure 3) in the File name box.
    Remember the file name MUST end in .java

    It is recommended that you save your program in your own directory (without any space in its name) in H drive.


    Figure 3: Saving the file as a JAVA document.

  4. Open Command Prompt

    Go to Start -> Command Prompt (highlighted in figure 4).


    Figure 4: Opening Command Prompt in Windows.

  5. Compiling and Running the Program

    Use cd to go to the directory where the JAVA program is saved in.
    Use dir to see the files in the directory.

    When you are in the desired directory, you can compile the program by javac [filename.java].

    After the file is compiled, you can run it by java filename


    Figure 5: Compiling and Running the JAVA program.