Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




Thinking in Java
Prev Contents / Index Next

Compiling and running

To compile and run this program, and all the other programs in this book, you must first have a Java programming environment. There are a number of third-party development environments, but in this book we will assume that you are using the Java Developer’s Kit (JDK) from Sun, which is free. If you are using another development system,[14] you will need to look in the documentation for that system to determine how to compile and run programs.

Get on the Internet and go to There you will find information and links that will lead you through the process of downloading and installing the JDK for your particular platform.

Once the JDK is installed, and you’ve set up your computer’s path information so that it will find javac and java, download and unpack the source code for this book (you can find it at This will create a subdirectory for each chapter in this book. Move to subdirectory c02 and type:


This command should produce no response. If you get any kind of an error message, it means you haven’t installed the JDK properly and you need to investigate those problems.

On the other hand, if you just get your command prompt back, you can type:

java HelloDate

and you’ll get the message and the date as output.

This is the process you can use to compile and run each of the programs in this book. However, you will see that the source code for this book also has a file called build.xml in each chapter, and this contains “ant” commands for automatically building the files for that chapter. Buildfiles and Ant (including where to download it) are described more fully in Chapter 15, but once you have Ant installed (from you can just type ‘ant’ at the command prompt to compile and run the programs in each chapter. If you haven’t installed Ant yet, you can just type the javac and java commands by hand.
Thinking in Java
Prev Contents / Index Next

   Reproduced courtesy of Bruce Eckel, MindView, Inc. Design by Interspire