我无法将我的 Java 应用程序附加到远程 Java 虚拟机。 我在 Windows 7 上使用 java 8u45,我的附加代码非常简单
import java.io.IOException;
import java.util.List;
import java.util.Scanner;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import com.sun.tools.attach.spi.AttachProvider;
public class AgentLoader
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
String pid = s.next();
try
{
VirtualMachine vm = VirtualMachine.attach(pid);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
当调用 attach 时,我得到 AttachNotSupportedException 并且没有安装提供程序。 我浏览了网络上的一些答案,发现很少有不适合我的解决方案。 比如确保我不会在同一台机器上混淆几个 java 版本。 设置 PATH 变量指向位于 %JAVA_HOME%\jre\bin 的 attach.dll 库 等..
他们都不适合我
知道可能是什么问题吗? 谢谢
最佳答案
包括以下代码行,它应该可以工作。它需要 attach.dll 文件才能工作。
static
{
System.loadLibrary("attach");
}
关于java - 附加不支持异常 : no providers installed java agent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30325863/