This section provides a tutorial on how to start the JVM remote monitoring server 'jstatd' with an internal RMI registry and a security policy file.
In this tutorial, we are going to try to start the JVM remote monitoring server, "jstatd".
1. Run the "jstatd" command in a command window:
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jstatd
Could not create remote object
access denied (java.util.PropertyPermission
java.rmi.server.ignoreSubClasses write)
java.security.AccessControlException: access denied
(java.util.PropertyPermission
java.rmi.server.ignoreSubClasses write)
at java.security.AccessControlContext.checkPermission
(AccessControlContext.java:323)
at java.security.AccessController.checkPermission
(AccessController.java:546)
at java.lang.SecurityManager.checkPermission
(SecurityManager.java:532)
at java.lang.System.setProperty(System.java:727)
at sun.tools.jstatd.Jstatd.main(Jstatd.java:122)
The "access denied" error is expected, because "jstatd" requires a security policy
file specified with the "java.security.policy" system property, if there is no security manager
running on my machine.
2. Create the security policy file, tools.policy, that grants permissions to run "jstatd"
and other tools in the tools.jar:
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
3. Run "jstatd" with the security policy file, tools.policy specified to the "java.security.policy" system property:
"jstatd" is running correctly now. It created an internal RMI registry
and waiting at port 1234 for RMI protocol connections from remote machines by JVM monitoring tools.
See the next section on how to run "jps" and "jstat" tools from remote machines.