(This question is similar to How to find a list of Java agents connected to a running JVM?. For the sake of completeness, I will add this answer to both questions.)
Checking agents that have been added using the Attach API:
If you are interested in agents that were added to the application at runtime using the Attach API, you can use DiagnosticCommandMBean . This bean offers a diagnostic command called vmDynlib , a parameterless method that returns a String listing all dynamically loaded libraries.
Here is a snippet of code that prints all the dynamic libraries loaded by the application virtual machine:
ObjectName diagnosticsCommandName = new ObjectName("com.sun.management:type=DiagnosticCommand"); String operationName = "vmDynlibs"; String result = (String) ManagementFactory.getPlatformMBeanServer().invoke(diagnosticsCommandName, operationName, null, null); System.out.println(result);
This leads to a conclusion similar to this:
Dynamic libraries: 0x00007ff7b8600000 - 0x00007ff7b8637000 C:\Program Files\Java\jdk1.8.0_181\bin\java.exe 0x00007ffdfeb00000 - 0x00007ffdfecf0000 C:\WINDOWS\SYSTEM32\ntdll.dll 0x00007ffdfe300000 - 0x00007ffdfe3b2000 C:\WINDOWS\System32\KERNEL32.DLL 0x00007ffdfbb30000 - 0x00007ffdfbdd3000 C:\WINDOWS\System32\KERNELBASE.dll 0x00007ffdfe950000 - 0x00007ffdfe9f3000 C:\WINDOWS\System32\ADVAPI32.dll ...
You can then check this text if it contains a specific .so or .dll file.
The same check can be performed non-programmatically.
You can use the jconsole tool for this.
Connect to the virtual machine, switch to the MBeans tab, select com.sun.management , select DiagnosticCommand , select Operations , select vmDynlibs and call it.

In the picture you can see one of my test agents attached to the application. The agent was connected using the Attach API , so this agent will not be visible when checking the command line arguments of the application (i.e. -agentpath=... will not be visible in the arguments), but only the dynamically loaded library is visible.
Checking agents that were added via the command line:
To get the full link, I will also post how to detect agents that have been added through the command line. You can check them using RuntimeMXBean .
This bean offers the getInputArguments method, which returns a list of all VM arguments. You can agentpath over the list and check for agentpath , agentlib and javaagent , similar to the following code snippet:
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); List<String> jvmArgs = runtimeMXBean.getInputArguments(); System.out.println("JVM arguments:"); for (String arg : jvmArgs) { if (arg.startsWith("-agentpath") || arg.startsWith("-agentlib") || arg.startsWith("-javaagent")) { System.out.print("***** "); } System.out.print(arg); if (arg.startsWith("-agentpath") || arg.startsWith("-agentlib") || arg.startsWith("-javaagent")) { System.out.println(" *****"); } else { System.out.println(); } }