While using attach API in Eclipse error is thrown in console.
In order to use attach API I went to installed JRE in eclipse and then using edit option included the tools.jar in the external jars option in current JRE.
But it throws the following error when i try to execute a simple program such as
java.lang.UnsatisfiedLinkError: no attach in java.library.path com.sun.tools.attach.AttachNotSupportedException: no providers installed at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:190) at dynamicLoadingTest.VMAttach.main(VMAttach.java:17)
This is the simple program executed. import java.io.IOException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
public class VMAttach {
public static void main(String[] args) {
try {
VirtualMachine vm = VirtualMachine.attach("6832");
} catch (AttachNotSupportedException e) {
System.out.println("This error");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
The process id mentioned 6832 is of a Java application running on the system
On changing the installed jre to jdk following error is produced
Exception in thread "main" com.sun.tools.attach.AttachNotSupportedException: jvm.dll not loaded by target process
at sun.tools.attach.WindowsVirtualMachine.<init>(WindowsVirtualMachine.java:46)
at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:52)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:195)
at dynamicLoadingTest.VMAttach.main(VMAttach.java:17)
Actually, This problem orignates when you have diffrent jdks in your system and all are included on the class path.
For me, the solution was to put attach.dll
from the JDK (same version as your JRE) into the JRE's bin
directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With