在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中

netstat -ano

将列出所有监听的协议、端口和进程。 使用

taskkill -pid "proces to kill" /f

关闭侦听该端口的进程。 如

 taskkill -pid 431 /f

其他回答

是的,正如Guido Simone所说,这是因为另一个进程侦听相同的端口。如果你使用的是Ubuntu,你可以简单地杀死这个进程 Sudo kill $(Sudo lsof -t:[端口号])

sudo kill $(sudo lsof -t:8080)

但有一次它对我不起作用。 我下了命令

$ lsof -i:[port] 

它什么也没有显示。

我使用命令检查了我的docker容器 Docker ps -a,但他们都死了。所有集装箱都停了 (但我记得,我停了一个集装箱,几分钟前使用的是同一个港口。)为了确保docker不是原因,我使用命令sudo service docker stop停止整个docker进程,然后再试一次。 令人惊讶的是eclipse当时并没有显示错误。它完美地运行了我的程序。

希望我的经验能帮助到一些人。

如果你知道进程运行的端口是什么,你可以输入: lsof我:<端口>。

例如,lsof -i:8080列出运行在端口8080上的进程(pid)。

然后使用kill <pid>终止进程

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.

对于那些正在寻找最简单的答案的人(因为这是我们通常错过的),只需停止您正在运行的项目并重新开始。 大多数情况下,我们所做的是忘记停止我们之前运行的项目,当我们重新运行项目时,它会显示这样的问题。

我还附上了一张照片,让它更清晰(我使用“Spring工具套件”)。 所以你需要做的是点击最右边的按钮,如果你想重新启动同一个项目,或者首先点击右边第二个按钮来停止你的项目,然后点击最左边的按钮来运行你的项目。我希望这将解决少数新程序员的问题。:)

您的端口在其他进程中一定很忙。因此,您可以在https://technet.microsoft.com/en-us/sysinternals/bb897437上下载TCPView并为使用的端口终止进程。

如果你不知道你的端口,双击没有启动的服务器,然后点击打开服务器属性页,然后点击左边栏的glassfish。你会在这里找到港口。