I am developing an application in Netbeans, and it is using JavaDB. I can connect to it and execute queries without issues, but for some reason, the "Output - JavaDB Database Process" pane within Netbeans keeps displaying
Security manager installed using the Basic server security policy.
Could not listen on por开发者_开发问答t 1527 on host localhost:
java.net.BindException: Address already in use
How do I find out what process is already using, or bound to that port?
On Ubuntu Karmic, Netbeans 6.7.1
To find the pid of a process listening to the port 1527, either use:
$ netstat -ap | grep 1527
tcp6 0 0 localhost:1527 [::]:* LISTEN 31962/java
or
$ lsof -i :1527
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 31962 pascal 28u IPv6 13413903 0t0 TCP localhost:1527 (LISTEN)
And then:
$ ps aux | grep 31962 | grep -v grep
pascal 31962 0.1 0.2 674936 4172 pts/1 Sl May08 1:23 /usr/lib/jvm/java-6-sun/bin/java -classpath /usr/share/javadb/lib/derby.jar:/usr/share/javadb/lib/derbynet.jar:/usr/share/javadb/lib/derbytools.jar:/usr/share/javadb/lib/derbyclient.jar org.apache.derby.drda.NetworkServerControl start
And I'm pretty sure that what you'll find is the pid of a Java process corresponding to JavaDB (I don't know many processes using port 1527 apart from JavaDB). How did you actually start it?
PS: I'm using JavaDB that I'm starting on the command line, outside any IDE.
Two programs that would help you out are ‘lsof‘ and ‘netstat‘ both of which can provide this information. I would give you the arguments to call them with but I am using my oversized iPhone to answer and it is too cumbersome to look up. So that is left as an exercise for the reader ;-)
精彩评论