Quickly find your Java application process ID
In this article, we are going to discuss how to quickly find your Java Application Process ID. For some monitoring tools like yCrash, you must pass your application process ID as input. If you want to search for a more detailed article with several different options to find your app’s process ID, you can refer to this blog post.
SEE ALSO: “One of the most important aspects of the Java ecosystem is the diversity of people and technology”
Finding the Java Application Process ID on Linux
On any Linux / Unix version of the operating system, run the command:
ps -ef | grep java
The above command will display all the Java processes running on this machine and their arguments, the process ID and the user who started it. When I issued the above command, here is the output from my AWS EC2 Linux instance:
Fig: ‘PS’ command showing all Java processes running on a Linux machine
The red highlight in the figure above indicates the process IDs of all Java processes running on this EC2 instance. From there, you can get your app’s process ID.
Finding the Java Application Process ID in Windows
‘jps’ – Java Virtual Machine Process Status Tool is provided in JDK. This tool will display all Java processes running on this machine. Below are the steps to invoke the ‘jps’ command.
- open the command prompt.
- cd in the ‘bin’ folder, where JDK is installed
- Issue the ‘jps’ command
cd C:Program FilesJavajdk1.8.0_181bin jps
When the above command was issued the following output was:
Fig: ‘jps’ command displaying all the Java processes running on the Windows machine
The red highlight in the figure above indicates the process IDs of all Java processes running on this Windows instance. From there, you can get your app’s process ID. Note in my Windows machine I have 3 java processes running:
- Jps – JVM process status tool that I launched earlier
- Prime – Tomcat server process
- org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar – Eclipse IDE
To note: Unlike the ‘ps’ command on Linux (example given above), you will not see all the arguments of the Java process. A downside to this approach is that “jps” will only display the first command in the java process. You can see all the arguments of the java process, only when the ‘ps’ command is issued.