Using an Integrated Development Environment
Integrated Development Environments, or IDEs, can greatly
facilitate the task of creating applications. Mid-level code editors,
such as Crimson Editor, TextPad, or Edit-Plus, provide syntax highlighting,
automatic indenting, parentheses and curly-brace matching, and may
have tools to compile and execute programs.
High-end environments, such as Eclipse, NetBeans, or JDeveloper, offer
many additional features, such as project management, automatic deployment
for web applications, code refactoring, code assist, etc. But, these
additional capabilities come with the price of additional complexity
in the environment, particularly because they force you to create projects for even the simplest applications.
To use the class files in these environments, we must first have a workspace,
which is a collection of projects. Workspaces have various configuration
settings that will cut across all projects within all projects they
contain, such as which version of Java is in use, any added libraries,
etc. (a project is usually one application).
Both Eclipse and NetBeans use the workspace concept, but you can start
with any empty directory - the IDE will add its own special files as
you create projects.
In the Windows Explorer, navigate to your ClassFiles directory. If it does not contain a Workspace subdirectory, create it.
To use Eclipse with the class files, you can direct it to the workspace
(ClassFiles/Workspace) when it opens (if it asks), or use
if Eclipse is already running. Each chapter's
demo folder should be treated as a project, as should each Solution folder.
One limitation of these environments is that no project can contain
the same Java class twice, so our progressive versions of the Payroll
application solution require their own individual project. Also,
due to the way Java's package structures work, each Demo folder must
be a separate project, as with each subdirectory under Solutions.
To use the Exercises folder as an Eclipse project:
File, New ... Java Project
from the menu
is not immediately available,
first - the menu items are usage-sensitive).
- Name the project
Create project from existing source
- Browse to the Exercises directory, and
- You can then
the dialog box.
As we encounter each chapter, we can create a project using the Demos
directory for that chapter the same way we just created the Exercises project..
To create a Java class within a project, use
, and then
if that is available, or
. Provide a name and
In general, with the several applications that we will build upon progressively
(Game and Payroll), you can continue to work with the same files, and
add to them as we cover additional topics. If you want to check the
solutions, you can either open those files in a separate editor, like
Notepad, or create a project for that Solutions subdirectory. If you
wish to save a particular stage of the application for future reference,
you can just make a copy of the Exercises directory.
The examples and instructions going forward in this course assume the use of a basic text editor and the command line. You are free to choose which tool to use. If Eclipse becomes a problem, move to a simple editor. The focus of this course is on the Java Programming Language and not a particular tool.