How to Check Whether a Port is Free August 29, 2019 We can check if a given port is free by trying to construct a ServerSocket with the port that needs to be checked: import java.io.*;import java.net.*;public class CheckingIfPortIsFree{ public static