Tutorial Java 6 – #1 Prerequisites

This series of tutorials, beginning with this post, aims to synthesize elements of Java 1.6 for:

  • learning object-oriented programming (OOP) in Java 1.6;
  • learning for Sun Certified Java Programmer certification for Java 6 – SCJP;
  • to become a better programmer.

This tutorial, will synthesize a large amount of information. Therefore, a more complete and more detailed reading of books on Java is required to fully understand these topics. Among these recommendations are:

Head First Java, de Kathy Sierra, Bert Bates
The book has an interesting style of presentation, as all of the Head First series. For someone who now teaches Java is an excellent support.
SCJP Sun Certified Programmer for Java 6 Study Guide (CX-310-065): Exam 310-065, de by Kathy Sierra, Bert Bates


The book covers all the knowledge necessary to sustain the SCJP certification. It is very detailed and even for an experienced Java programmer  contains unused or unknown details, required for certification. The book contains a series of quiz tests that allows candidates to accommodate the style of the examination.


Regarding necessary software support, things are really simple. To develop Java applications you need:

  • a simple ASCII editor (Notepad, Notepad++, JEdit, or other) for writing source files;
  • Java compiler,  javac.exe to compile source code files, . java, and to obtain bytecode files with .class extension;
  • virtual machine (Java Virtual Machine – JVM), java.exe to run Java applications

These two executables are obtained by installing the Java SDK (Software Development Kit), JDK which is obtained from the java.sun.com site. Once installed the development kit, the two executables are available in C:\Program Files\Java\jdk1.6.0_16\bin if you chose the default location.

Developing a Java console application without a integrated development environment – IDE (NetBeans, Eclipse) requires the following steps:

  1. Edit the source code; to test this example, a classic Hello World Java application, define a folder, say D:\Java Workspace on D: disk;  open a text file with a .java extension (let’s name it HelloWorld.java) using an editor (Notepad, Notepad++, JEdit, or other); even if you don’t fully understand the source code, the concepts will be explained in subsequent posts; for now it is important not to change the file or the class name, HelloWorld;
public class HelloWorld
 	public static void main(String[] args)
		System.out.println("Hello World Java!");

2.   Open the command prompt; select Start, type cmd.exe and press Enter;

3.   Change the current directory to D:\Java Workspace; this is done with MS-DOS commands (each command is followed by Enter):

cd Java Workspace

4.   Check if the system knows where to find the two executables, java.exe and javac.exe; the test is done by trying to launch the compiler from the command prompt:

D:\Java Workspace> javac.exe

If you get this error

'javac' is not recognized as an internal or external command,
  operable program or batch file.

then system variables must be set to indicate the location of the executable javac.exe. This can be done in two ways:

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_16
set PATH=%JAVA_HOME%\bin
set CLASSPATH=%JAVA_HOME%\jre\lib;

If, the JDK has not been installed in C:\Program Files\Java\jdk1.6.0_16 or if the version is different than jdk1.6.0_16, then modify the commands accordingly.

After setting these environment variables, you can compile the source file HelloWorld.java

4. The source code is compiled with the command:

d:\Java Workspace> javac.exe HelloWorld.java

5. Run the application:

d:\Java Workspace> java.exe HelloWorld

Hello World Java !

Because for complex applications and examples it is not effective to use this approach, based on the command line, it is better to use an integrated development environment (IDE) for Java, like: