0

I want to start a Java agent on a Java applet running on jp2launcher. I manage to attach to jp2launcher.exe using this jattach tool and I can inspect that my agent .jar file gets loaded, but neither my preMain or agentMain gets called.

The same behavior occurs when I attach to the process using com.sun.tools.attach.VirtualMachine to attach to jp2launcher.exe and load the agent this way.

I have successfully used the above methods to start an agent on normal Java apps.

Any ideas why this happens and if it is possible to start a Java agent on an applet?


Edit:

It seems to be a security issue that causes agent load to fail. Haven't managed yet to load the agent neither by using jattach or tools.attach, but did that by using the JAVA_TOOL_OPTIONS environment variable.

setx JAVA_TOOL_OPTIONS "-javaagent:agent.jar -Djava.security.policy=file.policy"

with file.policy containing:

grant {
permission java.security.AllPermission;
};
crankedrelic
  • 463
  • 1
  • 5
  • 14
  • 2
    How do you determine that the jar file got loaded and/or that the agentMain method has not been called? – Holger Apr 29 '21 at 12:08
  • i use ProcessHacker https://processhacker.sourceforge.io/ to look at the handles of jp2launcher, and I can see my agent jar file. I log on the first line of my agentmain and no logs are created. – crankedrelic Apr 29 '21 at 13:47

0 Answers0