O'Reilly logo

Java Cookbook by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Interacting with the Environment

Introduction

This chapter describes how your Java program can deal with its immediate surroundings, what we call the runtime environment . In one sense, everything you do in a Java program using almost any Java API involves the environment. Here we focus more narrowly on things that directly surround your program. Along the way we’ll meet the System class, which knows a lot about our system.

Two other runtime classes deserve brief mention. The first, java.lang.Runtime, lies behind many of the methods in the System class. System.exit( ), for example, just calls Runtime.exit( ). This is technically part of “the environment,” but the only time we use it directly is to run other programs, which is covered in Section 26.2. The java.awt.Toolkit object is also part of the environment and is discussed in Chapter 12.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required