title: How do I attach a debugger to a Java program running with Commons Daemon Service Runner?
body: <p>I would like to do some debugging on a Java program running on Windows: backtrace, print some variables, set breakpoints, single-step through a critical function.</p>
  
  <p>The first thing I tried was <code>jdb -attach 5312</code>. This failed with "shmemBase_attach failed: The system cannot find the file specified". I found some <a href="https://stackoverflow.com/q/4220174/2404501">related</a> <a href="https://stackoverflow.com/q/5380118/2404501">questions</a> about that error message but they seem to be talking about a more complex scenario involving debugger and target on separate hosts.</p>
  
  <p>What I'm doing is a local process attach, so I think it should be easier. But there is something making it harder.</p>
  
  <p>The target process isn't run as <code>java -jar foo.jar</code> or anything normal like that. It's an application-specific EXE file wrapping the java code. It identifies itself in a process listing as "Commons Daemon Service Runner" and looking at the strings inside it, it seems to be <a href="https://commons.apache.org/proper/commons-daemon/procrun.html" rel="nofollow noreferrer">the <code>prunsrv</code> program from Apache Commons Daemon</a>.</p>
  
  <p>Process Explorer tells me that there are no command line arguments, and the process is a child of services.exe. I have the ability to start and stop it from Windows Services, but I don't know how to do anything else with it.</p>
  
  <p>The <code>jps</code> command doesn't show this process, but I know that it is a Java program... lightly wrapped. Is there any way to debug it?</p>