在使用Java Attach API时,我只在Linux上得到以下链接错误(在不同的机器上尝试过):
Exception in thread "main" java.lang.UnsatisfiedLinkError: sun.tools.attach.WindowsAttachProvider.tempPath()Ljava/lang/String;
at sun.tools.attach.WindowsAttachProvider.tempPath(Native Method)
at sun.tools.attach.WindowsAttachProvider.isTempPathSecure(WindowsAttachProvider.java:74)
at sun.tools.attach.WindowsAttachProvider.listVirtualMachines(WindowsAttachProvider.java:58)
at com.sun.tools.attach.VirtualMachine.list(VirtualMachine.java:134)
at sun.tools.jconsole.LocalVirtualMachine.getAttachableVMs(LocalVirtualMachine.java:151)
at sun.tools.jconsole.LocalVirtualMachine.getAllVirtualMachines(LocalVirtualMachine.java:110)
...有趣的是,在Solaris和Windows上,它正在开箱即用。
我尝试了几种指定java.library.path的组合,以指向包含libattach.so的目录,但没有成功。
这里怎么了?
还有一个额外的问题:
有办法查看哪个本机库实际上绑定到一个java类吗?
发布于 2013-03-08 10:48:39
在不同的平台上使用不同的AttachProvider。在Linux上,它不应该使用sun.tools.attach.WindowsAttachProvider。它适用于Windows。
[solaris] sun.tools.attach.SolarisAttachProvider
[windows] sun.tools.attach.WindowsAttachProvider
[linux] sun.tools.attach.LinuxAttachProvider这是在资源文件META-INF\services\com.sun.tools.attach.spi.AttachProvider中配置的(通常该文件存在于tools.jar中)。它将搜索CLASSPATH以获得该资源文件的第一次出现,并从中读取AttachProvider实现类。
因此,您可能可以通过在CLASSPATH中搜索sun.tools.attach.WindowsAttachProvider来解决这个问题。可能您已经包含了来自Windows的tools.jar。
https://stackoverflow.com/questions/15290526
复制相似问题