Java tutorial
//package com.java2s; import java.io.IOException; import java.net.ServerSocket; public class Main { public static boolean portIsUsing(int port) { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(port); } catch (IOException ex) { return true; } try { serverSocket.close(); } catch (IOException ex) { } return false; } }