Is there a way to find a port opened by java process, given the process id of the process in java?
Need to find it using java as it has to be platform independent
Given a process id : output any port/socket connections being used by that process.
Few things given:
Process running in same jvm.
There is only 1 port/socket being used by that Process,
for which the Pid is given.
Can not do platform specific commands like ps -au | grep pid | ...
解决方案
The answer is no. What processes have what ports is not information available to java applications at all. You'd need JNI and it would depend on the operating system.