How to run the programs?

A scientist has to learn how to use tools do do experiments. For example an astrophysicist knows a lot about telescopes. A biologist visualizes organic cells under a microscope. A programmer has lots of tools available to run computer programs. The programs are written in a programming language called Java version 1.5.

I know a person who knows about programming and Java
I want to learn how to run the programs by myself  
    1. Install the Java Development Kit (JDK6) into your computer
    2. Download the programs from this website into your computer
    3. Compile the programs
    4. Execute the Java programs
What are all these names? Java - JDK - JRE - IDE - JVM - Compiler - Editor - Command line

I know a person who knows about programming and Java

Wonderful! Seek help from a teacher, a coworker or a friend familiar with programming. Show this web page to that person. Tell them you need help executing programs written in Java version 1.5. You will quickly be up and running.

I want to learn how to run the programs by myself

1. Install the Java Development Kit (JDK 6) into your computer

You need to install Java programming tools on your computer. These tools are free and can be downloaded from the Internet. You must download and install the free tool called Java SE Development Kit 6 (JDK 6). Your computer can then compile and execute the Java programs from the book. Follow these step by step instructions from the company that created the Java language. If you have a Windows computer follow "Hello World!" for Microsoft Windows

At this point you can compile and execute Java programs.

2. Download the programs from this website into your computer

On Windows open the console also known as the command prompt or command line.
Open the Command Prompt on a Windows computer

The following console opens up.
Console prompt is now ready

Create a directory named science under the C: drive. Type in the following four commands. After each command press the key 'Enter'.
cd c:\
mkdir science
cd science
Create a directory science under C drive
The first command takes you at the top of the C drive.
Second command creates a subfolder named science.
Third command moves you into this newly created subfolder
Finally we verify this new directory is empty. We now are going to download Java programs into this location.

For the first activity right click on the following link and save this file onto your computer to C:\science.
Save downloaded Java program into C:\science folder

 In the command prompt, type in the following command again.
In console prompt, verify the program has been downloaded with the command dir
The folder science now contains the java Program downloaded from this website.

3. Compile the programs

Type in the following command. This runs the java compiler javac.exe and instruct it to compile the Java program located in the current directory c:\science
If you get the following message 'javac.exe' is not recognized as an internal or external command you either did not install the JDK or the JDK's location is not set in your environment. Install the JDK following step 1 above. If you installed the JDK specify the exact location of the javac.exe java compiler program. For example the javac.exe can be found under "C:\Program Files\Java\jdk1.6.0_01\bin\javac" on my computer.
"C:\Program Files\Java\jdk1.6.0_01\bin\javac"
Verify the Java program was correctly compiled. At least one new file PseudoRandom.class should have been created by the Java compiler
The java compiler created class files
The compiler created the file PseudoRandom.class, PseudoRandom$Screen.class and PseudoRandom$Screen$1.class

4. Execute the Java programs

In the Command Prompt, type in the following command to execute the Java program PseudoRandom.class
java PseudoRandom
Execute Java program PseudoRandom
A new window appears with the name of the Java program. The program is successfully executing!
To stop the program click the red cross at the top right corner. You can then return to the Command Prompt and reexecute the program.
Note the command is java PseudoRandom. It is not java PseudoRandom.class. You must omit the '.class' extension even though this is really PseudoRandom.class that will be executed.
Note the current folder is the folder science that contains the Java program PseudoRandom.class. If the program is not in the current folder then the java.exe application will not be able to execute the Java program.

You can repeat steps 2 to 4 for each activity. All the files must be saved under the same folder.
All Java programs are installed in the same folder c:\science
Tip: you can compile all the java programs under the current folder with the following command
javac *.java

What are all these names? Java - JDK - JRE - IDE - JVM - Compiler - Editor - Command line