Question

I 've started a Java application with the args :

"-agentpath:C:\Program Files\jprofiler7\bin\windows-x64\jprofilerti.dll=port=8849,id=134,nowait"

then the console showed:

JProfiler> Protocol version 37
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Don't wait for frontend to connect.
JProfiler> Using config file C:\Users\user\.jprofiler7\config.xml (id: 134)
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
JProfiler> Hotspot compiler enabled

Then I could connect by JProfiler GUI now.

But I need connect that via another Java application with JProfiler API. How could I connect that ? By any VM argument ?

I just know maybe I have to create a connection first , but I don't know how to choose the session ID.

Connection connection = ConnectionFactory.createRemoteConnection("localhost", 8849, 30);

If I ran the agent application then connect via JProfiler GUi firstly ,I could get the cpu information by my Java application , including then running my JProfiler API application .

Profiling data :
Hot spots:
Top 5 hot spots:
Hot spot 1: ProfilerTest.main(java.lang.String[ ]): 34 ms (100 %)
Backtraces: 
ProfilerTest.main(java.lang.String[ ]): 34722 (0)
   ***: 34722 (0)
Cpu tree:
***: 34722 (0)
   ProfilerTest.main(java.lang.String[ ]): 34722 (0)
      java.util.Scanner.next(): 34722 (0)

But I'll get nothing if I ran the agent application then connect via my JProfiler API application firstly.

Profiling data :
Hot spots:
Top 5 hot spots:
Cpu tree:
***: 0 (0)
Was it helpful?

Solution

After ",nowait", add ",config=[path to config file],id=nnn" where "[path to config file]" is %USERPROFILE%.jprofiler8\config.xml and "nnn" is the session ID that is visible in the top-right corner of the application settings tab in the session settings dialog.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top