Java Dynamic Management Kit 5.1 Tools Reference Guide

3.4 Example of the proxygen Tool

The following example shows how to generate the managed object for the Simple class and SimpleMBean interface. You must compile the classes before using the proxygen tool to generate the managed object. Finally, you must compile the Java code generated by the proxygen tool.

The source code for the Simple class is contained in the installDir/SUNWjdmk/5.1/examples/legacy/MonitorMBean directory, where installDir is the directory under which the Java DMK was installed.


Note –

On the Solaris platform, the installDir file hierarchy is not writable by default. In this case you must copy the Simple.java and SimpleMBean.java files to a directory where you have write permissions.


To Generate the Managed Object for the Simple Class
  1. Add the following to your CLASSPATH:

    • In the Solaris or Linux operating environment.


      installDir/SUNWjdmk/5.1/lib/jdmkrt.jar  
      installDir/SUNWjdmk/5.1/lib/jdmktk.jar
      installDir/SUNWjdmk/5.1/lib/jmx.jar

    • In a Windows 2000 operating environment.


      installDir\SUNWjdmk\5.1\lib\jdmkrt.jar
      installDir\SUNWjdmk\5.1\lib\jdmktk.jar
      installDir\SUNWjdmk\5.1\lib\jmx.jar

  2. Type the following commands.


    prompt% javac Simple.java SimpleMBean.java
    prompt% /.../bin/proxygen -classpath . Simple
    Destination directory set to ./.
     
    Starting compilation of Simple.
     
    Starting to generate stub SimpleProxy.java for class Simple
    Starting to generate MBean interface SimpleProxyMBean.java for class Simple

    Proxy MBeans generated using the proxygen tool in Java DMK 4.2 must be regenerated to run in Java DMK 5.1, because some of the methods used in version 4.2 have been deprecated. However, proxy MBeans generated using the proxygen tool in Java DMK 5.0 do not need to be regenerated to run in Java DMK 5.1.