The JavaTM Tutorial

| Start of Tutorial | Search Feedback Form

## Trail: Essential Java Classes

> > Your feedback is important to us! Please send your comments and suggestions to us using the feedback page.

> This trail discusses classes from the Java platform that are essential to most programmers. In particular, it focuses on classes from the `java.lang` and `java.io` packages, including these:
> - `Properties`
> - `System`
> - `SecurityManag`er
> - `Thread` and its related classes
> - `Throwable` and `Exception`, and their friends
> - The `Reader`, `Writer`, `InputStream`, and `OutputStream` classes from `java.io` and their descendants
> Like the rest of the tutorial, this trail is designed so that you can skip around. Feel free to read only the lessons for the classes that interest you.

> Setting Program Attributes describes how you can set attributes for your Java programs through the use of properties and command-line arguments. Use properties to change attributes for every invocation of your program; use command-line arguments to change attributes for only the current invocation of your program.

> Accessing System Resources shows you how, through the `System` class, your Java programs can manage properties, set up a security manager, and access system resources such as the standard input and output streams. The `System` class provides a system-independent programming interface to system resources, thus allowing your programs to use them without compromising portability. This lesson also contains a brief discussion of the `Runtime` class and why most programmers should avoid using it.

> Handling Errors with Exceptions explains how you can use Java's exception mechanism to handle errors in your programs. This lesson describes what an exception is, how to throw and catch exceptions, what to do with an exception once you've caught it, and how to best use the exception class hierarchy provided by the Java platform.

> Doing Two or More Tasks at Once: Threads discusses in detail the use of threads that enable your Java applications or applets to perform multiple tasks simultaneously. This lesson describes when and why you might want to use threads, how to create and manage threads and thread groups in your Java program, and how to avoid common pitfalls such as deadlock, starvation, and race conditions.

> > This tutorial provides basic information about using threads. Do you need more advanced information than provided here? Check out the second edition of Doug Lea's book, Concurrent Programming in Java, Second Edition. This book shows readers how to use the Java platform's threading model more precisely by helping them to understand the patterns and tradeoffs associated with concurrent programming. The second edition is available from amazon.com.

> Reading and Writing (but No 'rithmetic) describes the process of getting information into your program and sending it out again through the use of the stream classes in `java.io`. Reading and writing information provides the basis for all kinds of interesting behaviors, such as serializing objects, invoking methods on objects in another VM, communicating over a network, or just accessing the file system.

| Start of Tutorial | Search Feedback Form