The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →In JDK 10, get the process ID of the JVM running your application with ProcessHandle.current().pid():
long pid = ProcessHandle.current().pid();
Get the current Java app’s process ID
ProcessHandle.current() returns a handle to the process running the current code, and pid() returns that process’s native operating-system ID. Both APIs are in java.lang and have been available since Java 9, so they are available in JDK 10. See Oracle’s JDK 10 ProcessHandle API.
long pid = ProcessHandle.current().pid();
System.out.println("Process ID: " + pid);
The result is a process ID assigned by the operating system, not a Java thread ID or a JVM-internal identifier. Its numeric range depends on the operating system.
Get the ID of a process started by your code
If you already have a Process object for a process launched with ProcessBuilder or Runtime.exec, call pid() on that object instead:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsProcess process = new ProcessBuilder("some-command").start();
long childPid = process.pid();
This returns the native process ID of the process represented by that Process, which may be a child process rather than the JVM running your application. In JDK 10, Process.pid() obtains the ID through toHandle().pid(). See Oracle’s JDK 10 Process API.
| What you need | Call | What it identifies |
|---|---|---|
| The JVM running this code | ProcessHandle.current().pid() |
The current Java application’s operating-system process |
A process represented by a Process object |
process.pid() |
The operating-system process represented by that object |
Use a PID as a temporary identifier
A PID is useful for reporting a process or looking it up in operating-system tools, but it is not a permanent identity. When a process terminates, the operating system may reuse its PID for another process. Process status can also change asynchronously, so a saved PID alone is not proof that the same process is still running.
Rank #2
For more process details, ProcessHandle.Info provides values such as the command, command line, start time, arguments, and user. Availability varies with the operating system and the requesting process’s privileges. These accessors return Optional values; check whether each value is present before using it. See Oracle’s JDK 10 ProcessHandle.Info API.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.

