How to dynamically attach using JRE's java.exe?

Mandy Chung Mandy.Chung at Sun.COM
Fri May 16 09:14:51 PDT 2008


Hi Bastian,

The attach API is in the JDK/lib/tools.jar.  So you will need to set the 
classpath to include tools.jar (e.g. java -classpath 
$JDK_HOME/lib/tools.jar YourApp).

You can refer to the example described in Alan Bateman's blog:
   http://blogs.sun.com/alanb/entry/another_piece_of_the_tool

Hope this helps.
Mandy

Bastian Helfert wrote:
> Hello everybody,
>
> I apologize for posting my question to this mailing list, but is there 
> anyone who can help me, please?
>
> How can I execute
>
>    VirtualMachine.attach(pid);
>
> by using the java app launcher of the JRE for Windows (i.e. instead of 
> the java.exe that ships with the JDK)?
>
> I have tried to set:
>
>    -Djava.library.path=%JDK_HOME%\jre\bin\attach.dll
>
> and also
>
>    
> -Dcom.sun.tools.attach.spi.AttachProvider=sun.tool.attach.WindowAttachProvider
>
> which possibly is nonsense, but I still receive the error:
>
>    java.lang.UnsatisfiedLinkError: no attach in java.library.path
>    Exception in thread "main" 
> com.sun.tools.attach.AttachNotSupportedException: no providers installed
>        at 
> com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:190)
>        ...
>
> Has anyone a solution to this (besides using the JDK's java.exe)? If 
> so: What libraries / properties do I need to provide / set and how? 
> What else do I need to do and how?
>
> Thank you very much in advance,
> Bastian




More information about the serviceability-dev mailing list