9

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) 
5
  • Seems you need to add library again Commented Jan 12, 2013 at 8:31
  • 1
    yeah this problem is also originating on my system also. Commented Jan 12, 2013 at 8:34
  • @sansix i have done it again but the the problem remains Commented Jan 12, 2013 at 8:34
  • @SanyamGoel try looking at this stackoverflow.com/questions/5565356/… Commented Jan 12, 2013 at 8:37
  • @sanix i have checked the java library path it contains the path to jdk library where the tools.jar is located Commented Jan 12, 2013 at 17:48

3 Answers 3

8

Actually, This problem orignates when you have diffrent jdks in your system and all are included on the class path.

Sign up to request clarification or add additional context in comments.

1 Comment

Can this answer be expanded on? How would this be detected and/or solved?
3

For me, the solution was to put attach.dll from the JDK (same version as your JRE) into the JRE's bin directory.

Comments

1

I tried the same with JDK1.7 and it is working fine. With JDK1.6 the problem remains .

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.