【发布时间】:2012-12-26 19:49:03
【问题描述】:
在 Eclipse 中使用附加 API 时,控制台会抛出错误。
为了使用附加 API,我在 eclipse 中安装了 JRE,然后使用编辑选项将 tools.jar 包含在当前 JRE 的外部 jars 选项中。
但是当我尝试执行一个简单的程序时,它会抛出以下错误,例如
java.lang.UnsatisfiedLinkError: java.library.path 中没有附加 com.sun.tools.attach.AttachNotSupportedException:没有提供者 安装在 com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:190) 在 dynamicLoadingTest.VMAttach.main(VMAttach.java:17)
这是执行的简单程序。 导入 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();
}
}
}
提到的进程id 6832是系统上运行的Java应用程序
在将安装的 jre 更改为 jdk 时会产生以下错误
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)
【问题讨论】:
-
看来你需要重新添加库
-
是的,这个问题也源于我的系统。
-
@sansix 我又做了一次,但问题仍然存在
-
@SanyamGoel 试试看这个stackoverflow.com/questions/5565356/…
-
@sanix 我已经检查了 java 库路径,它包含 tools.jar 所在的 jdk 库的路径
标签: java instrumentation agent attach-api