Check if port is used on windows machine
To check if a port is currently in use on a Windows machine, and then get some clue as to what’s using it, run the netstat program from a command console.
- Start > Run
- Enter cmd
- In the command console enter:
netstat -ano|grep portNumber
This lists any processes where the port number is included somewhere on the line.
- Look at the first number (in the second column). If this shows the port number after a colon, this means the port is currently being used.
- Make a note of the number at the end of the line. This is the process ID (PID).
- Run the ps program and grep for this PID:
ps -ef|grep PID
Here I was checking what was using port 4485.
C:\Documents and Settings\Administrator>netstat -ano|grep 4485
TCP 184.108.40.206:4485 220.127.116.11:80 CLOSE_WAIT 2444
C:\Documents and Settings\Administrator>ps -ef|grep 2444
Administrator 2444 - - Aug 02 - 0:16 GoogleDesktopIndex 3 5
It turned out GoogleDesktopIndex was using that port.
Maven and web project
Often times you create a maven project but want to pull in the project and its dependencies to deploy on the server. The following simple command can help you
mvn -DoutputDirectory=./lib dependency:copy-dependencies