Obtaining your Java Compiler and
Exploring your Java Environment
Become familiar with your Java compiler/development kit or
Interactive Development Environment (IDE)
IDEs (Interactive Development Environments) include:
I strongly recommend an IDE,
because it makes your life so much easier. However, you can
do development with the bare JDK and a simple text editor.
Here's what you'll need::
- Sun's JDK (Java Development Kit)
- You can choose the version you want to
download (I suggest you get the latest
version.) Note that the later the version,
the bigger the download!)
- Several of the components that we will be
using in this course must be separately
downloaded from the JavaSoft web pages.
Increasingly, these components are becoming
- Be sure to download both the JDK and
the associated documentation,
because you'll want to be able to browse the
API (they're all HTML pages, so you just use
a browser to view them).
- Alternatively, you can use the JDK version
supplied on the CD provided with a lot of
Java books (including Core Java, one of the
recommended books for the course).
Unfortunately, due to the the incredible pace
of change in the Java world, these can tend
to be rather out of date .
- If you're running on an Apple Macintosh, you
probably need to get the Mac OS Runtime for Java (MRJ)
. (Note that I know almost nothing about
Macs, so I can't really advise you on what's
good to do on that platform!)
- An editor of some kind.
- A plain editor (not a word processor
like Word). It needs to generate simple ASCII
- There are quite a few editors available on
the Web for free, ranging from the simple to
- Some editors available on the Web are more
like simple IDEs. You can create Java source
code within them, including syntax coloring
in some, and you can compile and build your
programs from within the editor. However,
they usually lack Java debugging, which you
will probably find unsatisfactory. A good
example is Programmer's File Editor,
which is a very good general purpose
programmer's editor (for Microsoft Windows
systems only); you may have to manually
configure it for Java.
- Windows 95/98/NT comes with Notepad,
which is pretty rudimentary; I would
recommend something better than that!
- UNIX systems come with an editor like vi.
Often emacs is available,
too. If emacs doesn't come with your system,
you can download a version (see: http://www.gnu.org/software/emacs/emacs.html)
- A lot of Java books come with a CD containing
useful stuff; Core Java provides an editor
(TextPad) on its CD which can be configured
to do syntax coloring, automatic invocation
of the Java compiler, etc.
I really recommend getting some
kind of IDE -- using the bare JDK can be a real pain, and you
can spend more time fighting that than learning Java! On the
other hand, if you're a real dyed-in-the-wool command mode
honcho, go for it!
Here is a list of things you need to do:
- If you haven't done so already, install the software
on your system
- If necessary, configure your software/system
to set environment variables, etc.
- Be sure to read any Read.me files, etc.
- Learn how to use your IDE
- Read the documentation/help/tutorial/whatever
- These days, it seems that the
documentation for a lot of products
is not great, and is often not in
- Books often provide a superior
description of how to use a product.
- With an IDE, you will typically have to learn
- How to create one
- How to configure it/set the necessary
- Use the editor to create Java source
- Compile and build the project
- Run the resulting executable
- Debug it.
- It sounds like a lot, but it's usually a far
superior experience to using the bare-bones
tools provided by the JDK, which are pretty
- If you use just the JDK with an editor, you'll need
- Learn how to use the editor and, if
necessary, to configure it for programming in
- Learn how to use javac,
and other JDK utilities
- You'll need to make sure things (especially
environment variables) are configured
properly so that these utilities work.
You will need to pay close attention to how to set up the
- The PATH environment variable (the
installation of your JDK and/or IDE may take care of
- The main thing to look for is that the PATH
includes the /bin
directory of your chosen JDK as one its first
- It is critical that the PATH point to the
same JDK as the CLASSPATH, else wierd things
will likely happen.
- CLASSPATH (how this is done varies
with which environment you're using)
- Where your current working directory is.
- Where the input .java
files should be placed.
- Where the output .class
files are placed by the Java compiler.
- Where the input .class
files are expected to be located by the Java
critical thing is that the source code for a (public)
Java class must be placed in a file whose name is
identical to the Java class name (case is
important!), and whose filetype is .java. If you do
not do this, the Java compiler will refuse to compile
If you're using the JDK directly, or if your
IDE uses the JDK (most of them do in some way), try hard to
understand the following command line options:
(the Java compiler)
||Sets the user class path
||Sets the destination root
directory for class files
||Generates all debugging
||Prints messages about what
source files are being compiled and what class files are
(the Java Interpreter)
||Specifies where to look for
||Prints a message each time a
class file is loaded.
The -classpath behavior in JDK 1.2.x and beyond is
different from that for JDK 1.1.x !
If you're not using the JDK, then a lot of
this is taken care of for you by your IDE (although it's
often necessary to understand the JDK options in order to
interpret the IDE's options, which often map directly to the
JDK options). However, you do have to understand how to set
the proper parameters for your environment, and for the
project you're working on.