简体   繁体   English

如何捕获JVM_Bind异常:java.net.BindException:地址已在使用中

[英]How to catch JVM_Bind exception: java.net.BindException: Address already in use

How can i catch the Bind exception? 如何捕获绑定异常? i used the following lines 我用了以下几行

try{
    //some code
}
catch (java.net.BindException e) {
    //some code
}

and

try{
    //some code
}catch (BindException e) {
    //some code
}

but none of them is working giving me the error 但他们都没有给我错误

`java.net.BindException: Address already in use: JVM_Bind
java.net.DualStackPlainSocketImpl.bind0(Native Method)
java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:106)
java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190)
java.net.ServerSocket.bind(ServerSocket.java:376)
java.net.ServerSocket.<init>(ServerSocket.java:237)
...

Can anybody give me an idea? 有人可以给我一个主意吗? Thanks in advance :) 提前致谢 :)

Are you sure that the try block surrounds the code that throws the exception? 您确定try块包含引发异常的代码吗? I say, either it's not, or that the BindException is wrapped with some other Throwable before thrown. 我说,要么不是,要么BindException在抛出之前被其他Throwable包装。 In that case, try 在这种情况下,请尝试

try {
    // the problematic code
} catch (Throwable t) { // <--- here, Throwable
   // better log the error here
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.net.BindException:地址已在使用中:JVM_Bind - java.net.BindException: Address already in use: JVM_Bind 线程“ Thread-0” java.net.BindException中的异常:已经使用的地址:JVM_Bind位于 - Exception in thread “Thread-0” java.net.BindException: Address already in use: JVM_Bind at 如何解决“java.net.BindException:地址已在使用:JVM_Bind”错误? - How do I resolve the "java.net.BindException: Address already in use: JVM_Bind" error? java.net.BindException:已使用的地址:JVM_Bind多客户机服务器 - java.net.BindException: Address already in use: JVM_Bind Multi Client Server java.net.BindException:已在使用的地址:JVM_Bind <null>:80 - java.net.BindException: Address already in use: JVM_Bind <null>:80 当我在Eclipse Mars中启动Jetty时,“ java.net.BindException:地址已在使用中:JVM_Bind” - “java.net.BindException: Address already in use: JVM_Bind” when I start Jetty in eclipse mars java.net.BindException:地址已在使用中:JVM_Bind但没有端口在使用它 - java.net.BindException: Address already in use: JVM_Bind BUT NO port using it ServerSocket端口问题(java.net.BindException:已在使用的地址:JVM_Bind) - ServerSocket port issue (java.net.BindException: Address already in use: JVM_Bind) 修复java.net.BindException:已使用的地址:JVM_Bind - Fixing java.net.BindException: Address already in use: JVM_Bind Tomcat:java.net.BindException:地址已在使用:JVM_Bind - Tomcat : java.net.BindException: Address already in use: JVM_Bind
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM