The JDK supplies a very impressive toolchest which enables you to monitor the JVM(
jconsole, jps, jmap,jvisualvm etc...). There are also other tools such as BTrace which can attach to the JVM and solve performance problems.
On UNIX you only need to use su or sudo and act as the user running the JVM. Doing that you can attach to it and apply all commands.
In Microsoft Windows the situation is more complicated. The service processes run under a different user and in another session and you are not able to connect to them.
But do not panic:-) I am suggesting here a simple workaround.
Download and install the Resource Kit Tools from Microsoft. (The 2003 version will also run on Windows XP). Didn't try Vista/2008 but then again who uses Vista.
Run the following command:
%RESKIT_HOME%\Tools\Instsrv.exe" SrvCMD "%RESKIT_HOME%\Tools\Srvany.exe"
It will create a service named SrvCMD (in case you have such a service use a different name)
Open services.msc and update the service properties to run manually. Check "allow service interact with desktop" box.
Open the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SrvCMD
Add a sub-key named Parameters
To this sub-key add a string value named Application. Its value will be the name of the executable you want to run. In our case c:\WINDOWS\system32\cmd.exe.
Note: If you are connecting with remote desktop make sure you are connecting with /console parameter (otherwise you will not see the command window)
Start the service.
A window with command prompt running in the session of the service will be opened.
jps will now discover your JVM.