Java:检查哪些进程绑定到端口?

发布于 2024-09-01 12:44:58 字数 403 浏览 7 评论 0原文

我正在 Netbeans 中开发一个应用程序,它使用 JavaDB。我可以连接到它并毫无问题地执行查询,但由于某种原因,Netbeans 中的“输出 - JavaDB 数据库进程”窗格不断显示

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

如何找出正在使用的进程,或绑定到该端口


在 Ubuntu Karmic、Netbeans 6.7.1 上

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一笔一画续写前缘 2024-09-08 12:44:58

要查找侦听端口 1527 的进程的 pid,请使用:

$ netstat -ap | grep 1527
tcp6       0      0 localhost:1527          [::]:*                  LISTEN      31962/java      

$ lsof -i :1527
COMMAND   PID   USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    31962 pascal   28u  IPv6 13413903      0t0  TCP localhost:1527 (LISTEN)

然后:

$ 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

我很确定您会找到与 JavaDB 对应的 Java 进程的 pid(我不知道很多进程)除了 JavaDB 之外,还使用端口 1527)。你实际上是如何开始的?

PS:我正在使用 JavaDB,它是在任何 IDE 之外的命令行上启动的。

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.

睡美人的小仙女 2024-09-08 12:44:58

两个可以帮助您的程序是“lsof”和“netstat”,它们都可以提供此信息。我会给你打电话的理由,但我用我的超大 iPhone 来接听,查找起来太麻烦了。所以这留给读者作为练习;-)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文