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;
};