在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

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


当前回答

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.

其他回答

重新启动电脑一次,我想它会工作。它开始在我身上起作用。还有一件事可以做,进入任务管理器并结束该过程。

在我的例子中,Tomcat在后台运行。我在使用Eclipse时将其安装为外部servlet。 在Intellij中使用Spring Boot,它有自己的服务器,但不能在已经被占用的情况下启动。 在我的例子中,Tomcat自动启动,我打开我的操作系统,这就是为什么我需要手动关闭他:

$ sudo service tomcat stop

当然,“tomcat”取决于您使用的tomcat版本。 希望能对别人有所帮助。

在Ubuntu/Unix中,我们可以通过以下两步来解决这个问题。

输入netstat -plten |grep java 这将给出一个类似于: tcp 00 0.0.0.0:8080 0.0.0.0:* LISTEN 1001 76084 9488/java 这里8080是java进程监听的端口号,9488是进程id (pid)。 为了释放被占用的端口,我们必须使用kill命令终止该进程。 杀死-9 9488 9488是之前的进程id。我们使用-9强制停止进程。

您的端口现在应该是空闲的,您可以重新启动服务器。

当另一个进程已经在指定端口(8080)上运行时,就会出现这个BindException异常。

您可以使用以下方法中的任何一种。

修改服务器端口号:如果使用Tomcat服务器和IntelliJ IDE,可以通过配置Tomcat服务器来配置服务器端口号

or

进入“tomcat>conf”文件夹 编辑server.xml 搜索“连接器端口” 将“8080”替换为端口号 重启tomcat服务器。

终止该端口中正在运行的现有进程并启动服务器。

对于Linux / Mac Sudo kill -9 $(Sudo lsof -t:8080) 对于Windows Netstat -ano | findstr:8080 taskkill /PID typeyourPIDhere /F 注意:(/F强制终止进程)

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.