Hello World in Java on Windows   (manual instructions)


This document instructs you on how to manually setup a Java programming environment for your Windows computer and provides a step-by-step guide for creating, compiling, and executing a Java program using either DrJava or the Command Prompt. All of the software is freely available on the Web.

These instructions are specialized to 64-bit Windows 8, but are similar for 32-bit and 64-bit versions of Windows 8, Windows 7, Vista, and XP.

You can defer steps 4–7 until Section 1.5 of the textbook.

We strongly recommend using our Windows installer instead of these manual instructions. The manual instructions do not include instructions for installing Checkstyle, Findbugs, or Java3D—none of these are required for COS 126.


0a.   Install Java


You will use Oracle's (previously Sun's) implementation of the Java Platform, Standard Edition Development Kit (JDK 7). Download the Java SE 7 Update 67 to the Desktop:

Once it is downloaded, install it by double clicking the file jdk-7u67-windows-x64.exe.


0b.   Install DrJava


You will develop your Java programs in an application called DrJava. DrJava features many specialized programming tools including syntax highlighting, bracket matching, auto indenting, and line numbering. To install DrJava:

Launch DrJava and make the following customizations:


1.   Create the Program in DrJava


Now you are ready to write your first Java program.


2.   Compile the Program from DrJava


It is now time to convert your Java program into a form more amenable for execution on a computer. To do this, click the Compile button. If all goes well, you should see the following message in the Compiler Output pane at the bottom:

Compilation completed.

If DrJava complains in some way, you mistyped something. Check your program carefully, using the error messages in the Compiler Output pane as a guide.


3.   Execute the Program from DrJava


Now it is time to run your program. This is the fun part.

Congratulations, you are now a Java programmer!


4.   Command-Line Interface


The command-line provides capabilities beyond those available in DrJava, including redirection and piping. You will type commands in an application called the Command Prompt.


5.   Compile the Program From the Command Prompt


You will use the javac command to convert your Java program into a form more amenable for execution on a computer.


6.   Execute the Program from the Command Prompt


You will use the java command to execute your program.


7.   Install the Standard Libraries


To use our standard libraries, you need to download them and add them both to your DrJava classpath and to your CLASSPATH environment variable.


Troubleshooting


I have a 32-bit version of Windows. What should I do?