gobbling up memory at an alarming rate, which stresses the processor of the
machine it's running on. The Java platform keeps you from having to worry about
this at all, because it has what's known as garbage collection.
The Java garbage collector is a background process that gets rid of objects that
aren't being used anymore, rather than forcing you to do that explicitly. Computers
are good at keeping track of thousands of things, and at allocating resources. The
Java platform lets the computer do that. It keeps a running count of references to
every object in memory. When the count hits zero, the garbage collector reclaims
the memory used by that object. You can manually invoke the garbage collector, but
I've never had to do so in my career. It usually handles itself, and certainly will for
every coding example in this tutorial.
IDEs versus command-line tools
As we noted before, the Java platform comes with command-line tools that let you
compile ( javac ) and run ( java ) Java programs. So why use an IDE like
Eclipse? Simply because using the command-line tools can be a pain in the neck for
programs of any complexity. They're there for you if you need them, but using an
IDE is most often the wiser choice.
The primary reason this is true is that an IDE manages files and paths for you, and
has wizards that assist you when you want to change your runtime environment.
When I want to compile a Java program with the javac command line tool, I have to
worry about setting the CLASSPATH environment variable ahead of time so that the
JRE can know where my classes are, or I have to set that variable at compile time.
In an IDE like Eclipse, all I have to do is tell Eclipse where to find my JRE. If my
code uses classes that I didn't write, all I have to do is tell Eclipse what libraries my
project references and where to find them. That is far simpler than using the
command line to type in heinously long statements that specify the classpath.
If you want or need to use the command-line tools, you can find out more about how
to use them at Sun's Java Technology Web site (see Resources ).
Section 5. OOP with Java technology
Introduction
Java technology covers a lot, but the language itself isn't huge. Covering it in
English, however, is no small task. This section of the tutorial will not cover the
language exhaustively. Instead, it will cover what you need to know to get started,
and what you're most likely to encounter as a beginning programmer. Other tutorials
(see Resources for pointers to some of them) cover various aspects of the language,
developerWorks® ibm.com/developerWorks
Introduction to Java programming
Page 12 of 65 © Copyright IBM Corporation 1994, 2007. All rights reserved.