# You want to run your FooServer on port 24600 but when you start it up you get a BindException
# because another process is already listening on that port

#==================================
# Approach 1: lsof (list open files)
#==================================

lsof | grep 24600

# result (PID is column 2 = 3527)
java       3527  chrisuser   41u     IPv6    5563481               TCP *:24600 (LISTEN)

#==================================
# Approach 2: netstat (list ports)
#==================================
# -a = show ports in all states
# -n = don't resolve IPs
# -t = show TCP sockets only
# -p = show process IDs
#==================================

netstat -antp | grep 24600

# result (PID is in last column = 3527)
tcp6       0      0 :::24600                :::*                    LISTEN     3527/java