10

I'm starting a java program from IntelliJ Idea which uses a .dll which is written by me in C++. After the startup of the application I can attach to the process using Microsoft Visual Studio (Debug / Attach to Process...) which allows me to debug the C++ part of the running application.

The name of the process is simply java. It is always a pain to select the right one from all the java processes. The simple Task Manager is not sufficient. The Process Explorer is good, but I still need to inspect multiple processes until I find the right one. It would be much easier for me if Idea would just tell the PID of the application it started.

Does Idea have such a feature?

(Win 7 64bit fresh @ 2017-04-19, Idea 2017.1.1)

Notinlist
  • 16,144
  • 10
  • 57
  • 99
  • 3
    Can you [get your own PID](http://stackoverflow.com/a/35885/104891) inside your app and print it in the console/log? – CrazyCoder Apr 19 '17 at 15:18

2 Answers2

30

You can list all java processes with the jps utility (Can be executed from Idea terminal window) which makes it extremely easy to identify your process. Example scenario:

D:\projects\git\CENSORED>jps
12084
5476 WorkerMain
8772 WebSocketProxyMain
9444 Launcher
12920 RemoteMavenServer
13400 Bootstrap
7752 Jps
Notinlist
  • 16,144
  • 10
  • 57
  • 99
  • 6
    Hint: `jps -l` prints package names too which helps distinguishing if you see multiple `Main` classes, like `com.intellij.idea.Main`. – Notinlist May 08 '18 at 14:12
0

If you have a profiling application like "JProfiler" you can also very easily find the pid in the "quick attach" dialog.

Invest
  • 545
  • 6
  • 9