go to previous page   go to home page   go to next page


No, not easily. Word processors such as Word create "binary" files that the Java compiler cannot use. Java source files must be text files. (Actually, Word can be forced to create a suitable file, but it is not worth the effort.)

Outline of the Steps

public class HelloPlanets
  public static void main ( String[] args )
    String[] planets = {"Mercury", "Venus",  "Earth",   "Mars", "Jupiter", 
                        "Saturn",  "Uranus", "Neptune", "Pluto"};
    for ( int j=0; j< planets.length; j++ )
      System.out.println("Hello " + planets[j] +"!" );


Above is an example Java program. Just for fun, the program is different than the previous examples.

Here is an outline of how to copy and run the program. You can try this now, or continue reading this chapter (which shows this step-by-step). These details may look involved. Actually, most of the steps are common operations with Windows environments.

For Most Windows Operating Systems:

  1. EXPLORE: Start File Explorer
    1. Find the folder icon on the taskbar at the bottom of the desktop.
    2. Click on it.
    3. You should see a hierarchical view of the hard disk and its folders.
  2. NAVIGATE: Navigate to a Folder
    1. "Navigate" with Explorer until you see the folder that will hold your program.
    2. Click on the folder (you may need to double-click).
      • You may make a new folder for this purpose.
      • In this example, C:\JavaSource will be used.
      • "Subdirectory" is another word for "folder".
    3. The right panel of Explorer shows the files in the folder
    4. A newly-created folder will be empty
  3. COMMAND: Start a command window and Notepad
    1. Put the mouse pointer in the right panel of Explorer.
    2. Make sure no file name is highlighted.
    3. Shift right-click. A menu pops up.
    4. Click on "Open Power Shell" (or similar)
    5. A command line window starts up
    6. Type Notepad to start Notepad
    7. You now have two new windows: the command line window and a window for Notepad.
  4. COPY: Copy the program into the clipboard.
    1. In the browser window (this window), put the mouse pointer on the "p" of "public" in the sample program.
    2. Push down on the left mouse button, then drag down thorugh the final "}" . The text you dragged over will be highlighted.
    3. Lift up on the mouse button.
    4. Click on the "Edit" menu of the browser and then click on "Copy". (Or type control-c) This makes a copy of the program in the clipboard, a section of the computer's main memory.
  5. PASTE: Paste into Notepad
    1. Right-click in the Notepad window.
    2. A menu pops up.
    3. Select "paste." (or type control-v)
    4. You now have have a copy of the program in Notepad.
  6. SAVE: Save the Source File
    1. Click on the "File" menu of Notepad and "Save As" HelloPlanets.java.
    2. You may have to "navigate" to the same folder as in step 2.
    3. Be sure that upper and lower case letters match the class name.
  7. RUN: Run the program:
    1. Click in the command prompt window.
    2. Type DIR to check that HelloPlanets.java is there.
    3. Compile the program: C:\JavaSource> javac HelloPlanets.java
    4. Run the program: C:\JavaSource> java HelloPlanets

(If you got through all of that, actual programming should be a cinch.)


How do you start Windows Explorer?

go to previous page   go to home page   go to next page