Running Example Programs

This chapter provides step-by-step instructions of writing a Java program using a text editor, and then compiling and running this program from command prompt. Several Integrated Development Environments (IDEs) are mentioned in this chapter. We have already installed NetBeans. That and Eclipse are the most popular in Java professional practice.

6. Step 4: Copy the program into the clipboard


The clipboard in Windows (and other GUI environments) is a utility that allows you to copy
from one program (like a web browswer) and paste into another (like Notepad.)

Step 4: Copy the program into the clipboard

Copy the program from the Web browser into the clipboard.

You very likely have done this before by copying between Word documents or copying from the web into Word or other programs. This is the same. Copy the program (below) into the clipboard, then paste into Notepad.

Here is the example program, again:

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] +"!" );


Highlight the program by clicking the mouse on the first character, and dragging to the last character:

  1. In the browser window (this window), put the mouse pointer on the "p" of "program".
  2. Push down on the left mouse button. Without lifting up on the mouse button, drag down until the final "}" of the program is covered.
  3. Lift up on the mouse button.
  4. Put the mouse pointer into the highlighted program.
  5. RIGHT-click.
  6. Select "Copy". (Or hit control-C)

Be careful not to click the mouse again in the window or you will cancel your selection. (But you can always start over.) After you have done this, you should see something like the following:


Question 7:

Could you paste what you just copied into Notepad?

Could you paste what you just copied into Notepad++?

Could you paste what you just copied into BlueJ?