Java Dynamic Management Kit 5.1 Tutorial

Preface

The JavaTM Dynamic Management Kit (Java DMK) 5.1 provides a set of Java classes and tools for developing dynamic management solutions. This product conforms to the Java Management Extensions (JMX), v1.2 Maintenance Release, and the JMX Remote API, v1.0. These specifications define a three-level architecture:

The JMX architecture is applicable to network management, remote system maintenance, application provisioning, and the management needs of the service-based network.

Once you are familiar with management concepts, the Java Dynamic Management Kit 5.1 Tutorial is intended to demonstrate each of the management levels and how they interact. The parts of this tutorial will show you:

Taken as a whole, these topics will demonstrate the complete development process for implementing a management solution in the Java programming language.

This book also features a part devoted to the details of programming simple network management protocol (SNMP) managers and agents (peers) using the Java DMK.

Changes Between Versions 5.0 and 5.1 of Java DMK

The following are the main changes and additions to Java DMK since the 5.0 release:

Who Should Use This Book

This tutorial is for developers who would like to learn how to instrument new or existing resources for management, write dynamic agents, or write management applications. You should be familiar with Java programming. Some tutorials also rely on system and network management concepts: knowledge of these is helpful, though not required.

This book is not intended to be an exhaustive reference. Management concepts and product features are covered in the Java Dynamic Management Kit 5.1 Getting Started Guide, and the complete API documentation generated by the JavadocTM tool are provided in the online documentation package.

Before You Read This Book

To build and run the sample programs in this tutorial or use the tool commands provided in the Java DMK, you must have a complete installation of the product on your system. Before programming with the Java DMK you should be familiar with the concepts and tools used throughout this tutorial.

Related Documentation

The Java DMK documentation set includes the following documents:

Book Title 

Part Number 

Java Dynamic Management Kit 5.1 Installation README

N/A 

Java Dynamic Management Kit 5.1 Getting Started Guide

816–7607 

Java Dynamic Management Kit 5.1 Tutorial

816–7609 

Java Dynamic Management Kit 5.1 Tools Reference Guide

816–7608 

Java Dynamic Management Kit 5.1 Release Notes

N/A 

These books are available online after you have installed the Java DMK documentation package. The online documentation also includes the API documentation generated by the Javadoc tool for the Java packages and classes. To access the online documentation, using any web browser, open the home page corresponding to your platform.

Operating Environment 

Homepage Location 

Solaris / Linux / Windows 2000 

installDir/SUNWjdmk/5.1/doc/index.html

In these file names, installDir refers to the base directory or folder of your Java DMK installation. In a default installation procedure, installDir is as follows.

These conventions are used throughout this book whenever referring to files or directories that are part of the installation.

The Java Dynamic Management Kit relies on the management architecture of two Java Specification Requests (JSRs): the JMX specification (JSR 3) and the JMX Remote API specification (JSR 160). The specification documents and reference implementations of these JSRs are available at:

http://java.sun.com/products/JavaManagement/download.html

Further Documentation

The structure of this book is based on the The Java Tutorial:

Some chapters in the part on SNMP refer to RFC standards for further information. The complete text of RFC papers can be found on the Internet site of the Internet Engineering Task Force:

http://www.ietf.org/

Disclaimer – This site is in no way affiliated with Sun Microsystems, Inc. and Sun makes no claim as to the accuracy or relevance of the data it contains.

Directories and Classpath

These tutorials are based on the example programs shipped with the Java DMK. Each example is a set of Java source code files in a separate subdirectory. The following table gives the location of the main examples directory:

Operating Environment 

Examples Directory 

Solaris / Linux / Windows 2000 

installDir/SUNWjdmk/5.1/examples

Within the examples directory, the examples themselves are separated into two sub-directories: legacy and current. This is to make a clear distinction between the examples that demonstrate the older implementations of features that have been superseded by the implementation of JMX Remote API in Java DMK 5.1. The implementations of features that have been deprecated in Java DMK 5.1 are now held in the legacy directory. The examples of the current features are held in current.

Except where noted, the source code in this book is taken from these example programs. However, some code fragments might be rearranged and comments might be changed. Program listings in the tutorials usually simplify comments and omit output statements for space considerations.

On the Solaris platform, you must have root access to write in the installed examples directory. For this reason, it might be necessary to copy all examples to a different location before compiling them. Throughout the rest of this book, we will use the term examplesDir to refer to the directory in which you compile and run the examples.

When either compiling or running the example programs, make sure that your PATH and CLASSPATH environment variables are correctly set to use the Java 2 Platform, Standard Edition (J2SE). In addition, your classpath must also contain the Java archive (JAR) files for the Java DMK runtime libraries, as well as the current directory (.). If you are using J2SE 1.4.x, then you must also include the runtime libraries for JMX and JMX Remote API, as well as other JAR files relating to the Simple Authentication Security layer (SASL) and Secure Sockets Layer (SSL) security mechanisms, should you require them.

At the time of writing, a Beta release of version 1.5.0 of the J2SE platform is available. The JMX API and the mandatory part of JMX Remote API have been included in J2SE 1.5, so if you are using version 1.5.0 of the J2SE platform, you do not need to add the jmx.jar, jmxremote.jar and SASL libraries to your class path.

For a Solaris or RedHat Linux platform, use the classpath given in Table P–1. For a Windows 2000 platform, use the classpath given in Table P–2.

Table P–1 Classpath for Compiling or Running the Examples on a Solaris or Linux Platform

J2SE Platform Version 

CLASSPATH

1.4.x 

installDir/SUNWjdmk/5.1/lib/jdmkrt.jar:
installDir/SUNWjdmk/5.1/lib/jmx.jar:
installDir/SUNWjdmk/5.1/lib/jmxremote.jar:
installDir/SUNWjdmk/5.1/lib/jmxremote_optional.jar:
installDir/SUNWjdmk/5.1/lib/sasl.jar:
installDir/SUNWjdmk/5.1/lib/sunsasl.jar:
installDir/SUNWjdmk/5.1/lib/rmissl.jar:
installDir/SUNWjdmk/5.1/lib/jdmktk.jar:.

1.5.0 (Beta) 

installDir/SUNWjdmk/5.1/lib/jdmkrt.jar:
installDir/SUNWjdmk/5.1/lib/jmxremote_optional.jar:.

If you installed the software in the default directory on a Solaris or Linux platform, installDir will be /opt.

Table P–2 Classpath for Compiling or Running the Examples on a Windows 2000 Platform

J2SE Platform Version 

Classpath 

1.4.x 

installDir\SUNWjdmk\5.1\lib\jdmkrt.jar;
installDir\SUNWjdmk\5.1\lib\jmx.jar;
installDir\SUNWjdmk\5.1\lib\jmxremote.jar;
installDir\SUNWjdmk\5.1\lib\mxremote_optional.jar;
installDir\SUNWjdmk\5.1\lib\sasl.jar;
installDir\SUNWjdmk\5.1\lib\sunsasl.jar;
installDir\SUNWjdmk\5.1\lib\rmissl.jar;.

1.5.0 (Beta) 

installDir\SUNWjdmk-runtime\lib\jdmkrt.jar:
installDir\SUNWjdmk-runtime-jmx\lib\jmxremote_optional.jar:.

If you installed the software in the default directory on a Windows 2000 platform, installDir will be C:\Program Files

These classpaths assume that you are in the subdirectory of a particular example when compiling or running it. Specify the classpath on the command line of the javac and java tools with the -classpath option. The J2SE platform version must match the version of the javac or java command that you are using.

Throughout the rest of this book, we will use the term classpath in command-line examples to indicate that you must use the classpath indicated in this section. You can also define this classpath in an environment variable according to your platform and omit its definition on the command line.

To use the mibgen tool and the deprecated proxygen tool provided with Java DMK, add the installation binary directory to your environment's path. The following table gives the location of this directory:

Operating Environment 

Binary Directories 

Solaris / Linux / Windows 2000 

installDir/SUNWjdmk/5.1/lib/jdmktk.jar

How This Book Is Organized

This book follows the organization of the The Java Tutorial. Each major part covers a subject and each chapter covers a topic within that subject.

Accessing Sun Documentation Online

The docs.sun.comSM Web site enables you to access Sun technical documentation online. You can browse the docs.sun.com archive or search for a specific book title or subject. The URL is http://www.oracle.com/technetwork/indexes/documentation/index.html.

Ordering Sun Documentation

Sun Microsystems offers select product documentation in print. For a list of documents and how to order them, see “Buy printed documentation” at http://www.oracle.com/technetwork/indexes/documentation/index.html.

Typographic Conventions

The following table describes the typographic conventions used in this book.

Typeface or Symbol 

Meaning 

Example 

AaBbCc123

The names of commands, files, and directories; on-screen computer output 

Edit your .login file.

Use ls -a to list all files.

machine_name% you have mail.

AaBbCc123

What you type, contrasted with on-screen computer output 

machine-name% su

Password:

AaBbCc123

Command-line placeholder: replace with a real name or value 

To delete a file, type rm filename.

AaBbCc123

Book titles, new words, or terms, or words to be emphasized. 

Read Chapter 6 in User's Guide.

These are called class options.

You must be root to do this.

Shell Prompts in Command Examples

The following table shows the default system prompt and superuser prompt for the C shell, Bourne shell, and Korn shell.

Shell 

Prompt 

C shell prompt 

machine-name%

C shell superuser prompt 

machine-name#

Bourne shell and Korn shell prompt 

$

Bourne shell and Korn shell superuser prompt 

#