Announcement

Collapse
No announcement yet.

Attach API

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attach API

    Hallo,

    mein kleines Programm versucht unter Windows XP über das attach API der VirtualMachine auf ein Applet zuzugreifen, welches über eine ProzessId (pid) angesteuert wird.

    Der Code:

    vm = VirtualMachine.attach (pid);

    String agent = "C:\\Programme\\Java\\jre1.6.0_07\\lib\\TestAgent. jar
    vm.loadAgent(agent, arg);

    Die Fehlermeldung zur Laufzeit: Agent JAR not found or no Agent-Class attribute

    Das jar-file befindet sich definitiv in diesem Verzeichnis und auch JAVA_HOME ist richtig gesetzt.

    Kann mir jemand weiterhelfen ?

    Danke

  • #2
    Tolles Forum !

    Comment


    • #3
      Ja, ist es....was erwartest du bei den Infos? Wie sieht das Manifest des JAR aus? Wer ist arg?
      Christian

      Comment


      • #4
        Hallo Christian,

        danke für Dein Interesse. Das obige Problem habe ich gelöst, d.h. der Agent wird geladen. Jetzt habe ich ein Problem mit dem Initialize. Im folgenden eine Beschreibung in Englisch:

        Hello,

        I am trying to attach to a running JVM under Windows XP with a valid process id ( via attach api).

        --------------------------------------------------------------------------------
        vm = VirtualMachine.attach (pid);

        String agent = "C:\\Programme\\Java\\jre1.6.0_07\\lib\\TestAg ent. jar
        vm.loadAgent(agent, arg);

        --------------------------------------------------------------------------------

        The following runtime error message occurs: "Agent JAR loaded but agent failed to initialize"

        The path to the agent seems to be correct and the load is working.

        The agents source code:



        --------------------------------------------------------------------------------

        import java.lang.instrument.ClassDefinition;
        import java.lang.instrument.Instrumentation;

        public class TestAgent {

        public TestAgent()
        {
        }

        /* NOTE: agentmain is the special method that
        will be called when this agent is loaded */

        public static void agentmain(String agentArgs, Instrumentation inst)
        throws Exception
        {
        System.out.println("Hello Mr. Bond..!");
        if (agentArgs != null) {
        System.out.println("my args are: " + agentArgs);
        }
        }
        }

        --------------------------------------------------------------------------------

        ...and the manifest.mf

        Manifest-Version: 1.0
        Agent-Class: TestAgent
        Can-Redefine-Classes: true

        Comment


        • #5
          http://forums.sun.com/thread.jspa?threadID=5345533
          Christian

          Comment


          • #6
            Ja, das ist die gleiche Frage, die ich in einem anderen Forum gestellt habe ;-)

            Comment

            Working...
            X