How to run the programs?
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
The following console opens up.
Create a directory named science under the C: drive. Type in the
following four commands. After each command press the key 'Enter'.
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 PseudoRandom.java and save this file onto
your computer to C:\science.
In the command prompt, type in the following command again.
The folder science now contains the java Program PseudoRandom.java
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 PseudoRandom.java 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" PseudoRandom.java
Verify the Java program PseudoRandom.java was correctly compiled. At
least one new file PseudoRandom.class should have been created by the
The compiler created the file PseudoRandom.class,
PseudoRandom$Screen.class and PseudoRandom$Screen$1.class
4. Execute the Java
In the Command Prompt, type in the following command to execute the
Java program PseudoRandom.class
A new window appears with the name of the Java program. The program is
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
You can repeat steps 2 to 4 for each activity. All the files must be
saved under the same folder.
Tip: you can compile all the java programs under the current
folder with the following command
What are all these names?
Java - JDK - JRE - IDE - JVM - Compiler - Editor - Command line
- Java is the name of a
programming language created in 1995. It is very popular among software
companies and universities. It is also the name of the application used
to execute Java applications. More...
- JDK is an acronym for
Java Development Kit. It is used to compile and execute Java programs.
The book requires version 5 or above. More...
- JRE is an acronym for
Java Runtime Environment. It is used to execute Java programs. The book
requires version 5 or above. More...
- IDE is an acronym for
Integrated Development Environment. It is a tool helping a programmer
creating software programs. A Java IDE helps a programmer create Java
programs. Programmers are often very passionate about their Java
they spend many hours of their work life with it. There are
many advanced tricks and features which makes life easier once you are
familiar with them.
Free Java IDEs include Eclipse, NetBeans and BlueJ. More...
- JVM is an acronym for
Java Virtual Machine. It is an application that knows how to execute
Java class files. The Java class files can be used on any kind of
computer however the computer needs the correct Java Virtual Machine to
be able to execute it. This is why it is called 'virtual'. This
application simulates a virtual machine that knows how to run Java
class files . Windows, Linux and Mac computers have different Java
Virtual Machines. The JRE includes a JVM named java or javaw. More...
- Compiler is an
application that converts text files created by a programmer into
binary files the computer understands. A Java compiler converts a Java
text file into a class file. The JDK includes a Java compiler
application named javac that produces class files. The Java Virtual
Machine knows how to execute class files.
- Editor is an application
used to edit text files. For Windows users, Notepad is the simplest
editor and can be used to edit simple Java programs. Developers prefer
using specific Java editors that color Java instructions such as 'for'
'if' 'else' making it easier to work with Java files. Java editors can
even provide suggestions to complete what you are currently typing -
this feature is called 'code assist'. Java IDE's provide powerful Java
editors that also show the location of syntax errors. More...
- Command line is an
application used to type in commands to a computer. It is often used by
developers to execute applications. If you don't use a Java IDE you can
compile Java programs and execute them directly through the command
line. You do so by calling the applications javac and java from the JDK
and JRE and passing the name of the Java programs to compile or