views:

284

answers:

2

Hi,

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 port 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

+1  A: 

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 ;-)

Ukko
+1 @Ukko : Thanks for the answer!
bguiz
+5  A: 

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.

Pascal Thivent
+1 and check @Pascal Thivent : Thanks for the answer, was spot on!
bguiz
> How did you actually start it?Well I checked the PPID, and it looked as if Netbeans had two instances of JavaDB runnign at once (I don't know how that happened) - it usually only has one.
bguiz