Java Reference
In-Depth Information
For the remainder of this topic, you will keep your Java source files in a folder
called JMXBook. In addition, you will use a setup batch file to set your PATH and
CLASSPATH for compiling and running the examples from the JMXBook direc-
tory. The batch file contains the following lines:
set CLASSPATH=c:\JMXBook;C:\jmx-1_0_1-ribin\jmx\lib\jmxri.jar;
C:\jmx-1_0_1-ribin\jmx\lib\jmxtools.jar;
C:\jmx-1_0_1-ri-bin\contrib\remoting\jar\jmx_remoting.jar;
set PATH=c:\jdk1.3\bin
The setup batch file is used to set up the JMX environment for compiling and
running the examples in a Windows environment. If you are using Unix, you will
need to modify the script accordingly. As you can see from the PATH environment
variable, we are using the JDK version 1.3, but every example should work with
any Java 2 Platform Standard Edition. When working from the command line,
you will invoke this file (setup.bat in our case) before doing anything else. After
running the setup script, you can test your CLASSPATH by typing java javax.man-
agement.ObjectName . You should get an error indicating that the class does not
contain a main() method.
Using Ant: For those of you familiar with Ant (or willing to find out
more), we included an Ant build system setup in appendix B. In the ap-
pendix you will find the Ant XML build doc and information for setting
up your environment.
NOTE
2.2 Managing your first resource
So far we have refreshed what you already know about the major JMX components,
and ensured that you have a good working environment. Now you are ready to cre-
ate your first MBean. Keep in mind that this chapter is intended only as an intro-
duction to MBeans; more complex examples are presented in later chapters.
For the first example, you'll create a simple HelloWorld MBean. The Hello-
World MBean exposes a Java String object, its only member variable, as a man-
ageable resource. We will use this example as a tool to introduce you to working
with the entirety of JMX , including the MBean server and the HTML adapter.
Remember, a manageable resource is any resource that can be accessed and con-
figured via an MBean. (For this chapter, don't worry about the coding standards of
MBeans. However, remember from chapter 1 that this topic covers three types of
MBeans: Standard, Dynamic, and Model. You will create only a Standard MBean
in this chapter; the exact rules for developing MBeans are presented in detail in
later chapters.) Figure 2.2 shows the UML diagram for the HelloWorld MBean.
Search WWH ::




Custom Search