9

EclipseでアタッチAPIを使用していると、コンソールでエラーがスローされます。

attach APIを使用するために、EclipseにインストールされたJREに移動し、編集オプションを使用して、現在のJREの外部jarオプションにtools.jarを含めました。

しかし、次のような単純なプログラムを実行しようとすると、次のエラーがスローされます

java.lang.UnsatisfiedLinkError:java.library.pathにアタッチがありませんcom.sun.tools.attach.AttachNotSupportedException:dynamicLoadingTest.VMAttachのcom.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:190)にプロバイダーがインストールされていません.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();
        }
    }
}

言及されているプロセスID6832は、システム上で実行されている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)
4

3 に答える 3

8

実際、この問題は、システムに異なるjdkがあり、すべてがクラスパスに含まれている場合に発生します。

于 2013-01-30T17:45:24.490 に答える
3

私にとっての解決策はattach.dll、JDK(JREと同じバージョン)からJREのbinディレクトリに配置することでした。

于 2015-08-10T12:06:22.557 に答える
1

JDK1.7でも同じことを試しましたが、正常に動作しています。JDK1.6では、問題が残ります。

于 2013-01-17T09:26:43.400 に答える