在Eclipse中,我得到了这个错误:

run:
     [java] Error creating the server socket.
     [java] Oct 04, 2012 5:31:38 PM cascadas.ace.AceFactory bootstrap
     [java] SEVERE: Failed to create world : java.net.BindException: Address already in use: JVM_Bind
     [java] Java Result: -1
BUILD SUCCESSFUL
Total time: 10 seconds

我不知道为什么现在出现了,但几个小时前它运行得很好。我需要重新启动我的机器吗?我该怎么查到底呢?感谢您的建议和建议。


当前回答

对于windows:

查找进程id Netstat -nao |查找8080

它将以数字的形式向您显示进程ID。

例子:

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       18856

这里18856是进程ID

终止这个过程 taskkill /PID 18856 /F

输出:SUCCESS: PID为18856的进程已被终止。

在这里使用taskkill是在杀死进程ID:18856

linux / Mac:

sudo kill -9 $(sudo lsof -t -i:8080)

在这里,您可以使用sudo lsof -t -i:8080找到端口8080的进程,并使用sudo kill命令杀死它

其他回答

对于windows:

查找进程id Netstat -nao |查找8080

它将以数字的形式向您显示进程ID。

例子:

TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       18856

这里18856是进程ID

终止这个过程 taskkill /PID 18856 /F

输出:SUCCESS: PID为18856的进程已被终止。

在这里使用taskkill是在杀死进程ID:18856

linux / Mac:

sudo kill -9 $(sudo lsof -t -i:8080)

在这里,您可以使用sudo lsof -t -i:8080找到端口8080的进程,并使用sudo kill命令杀死它

I faced similar issue in Eclipse when two consoles were opened when I started the Server program first and then the Client program. I used to stop the program in the single console thinking that it had closed the server, but it had only closed the client and not the server. I found running Java processes in my Task manager. This problem was solved by closing both Server and Client programs from their individual consoles(Eclipse shows console of latest active program). So when I started the Server program again, the port was again open to be captured.

这意味着其他进程已经在使用该端口。如果这个端口正在被其他一些重要的应用程序使用,而您不想关闭该应用程序,那么更好的方法是选择任何其他可以自由使用的端口。

将应用程序配置为使用任何其他空闲端口,您将看到应用程序正常工作。

(Windows)

要终止一个进程,首先需要找到进程Id (pid)

通过运行命令:

netstat -ano | findstr :yourPortNumber

你会得到你的进程Id (PID),现在要杀死相同的进程运行这个命令:

taskkill /pid yourid /f

端口已经被一些其他进程使用,@Diego Pino说你可以在unix上使用lsof来定位进程并杀死相应的进程,如果你在windows上使用netstat -ano来获得所有进程的pid和每个人获得的端口。搜索你的目标港口并杀死。

如果可能的话,重启你的机器就很简单了:)