I'd like to attach a Java agent to the running Java project in the IDE dynamically. To do that I have to find the ID of that process, then:
VirtualMachine vm = VirtualMachine.attach(ID);
How to find the ID of the process programatically?
Or how to attach a dynamic agent to the running process(if there is a simpler solution)?
Edit: I've found this method:
Set<String> getAttachedPids(@NotNull Project project)
but it gives me an empty set even if there is a java process running inside the IDE.