[英]Java server works in 32-bit, but not in 64-bit. Why?
I get this strange exception on only when running on 64 bit (windows 7 ultimate) Not when running 32 bit win7 ultimate. 我只有在64位运行时才会遇到这个奇怪的异常(Windows 7终极版)不是在运行32位win7终极时。 Currently its running on java version 1.6.0_26 目前它在java版本1.6.0_26上运行
running server!
java.net.SocketException: select failed
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.PlainSocketImpl.accept(Unknown Source)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at Server.main(Server.java:18)
Here is the code: 这是代码:
//import java.net.ServerSocket;
//import java.net.Socket;
import java.io.*;
import java.net.*;
public class Server {
public static void main(String[] args) {
System.out.println("running server!");
int nreq = 1;
try{
ServerSocket sock = new ServerSocket(7337);
for(;;){
Socket newsock = sock.accept();
System.out.println("Creating thread...");
Thread t = new ThreadHandler(newsock, nreq);
t.start();
nreq++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
The error referenced on line at points to this bit: 在指向此位的行上引用的错误:
Socket newsock = sock.accept();
You could definitely have an issue with windows 7 and the version of Java SDK you have installed. 您肯定会遇到Windows 7以及已安装的Java SDK版本的问题。 Download and install the latest version of Java SDK 7 from the oracle website. 从oracle网站下载并安装最新版本的Java SDK 7。 See if that helps. 看看是否有帮助。
These problems can happen, when there's a mismatch between JVM and OS. 当JVM和OS不匹配时,可能会发生这些问题。 One running 32 bit and the other running 64 bit. 一个运行32位,另一个运行64位。
I do not believe the problem is Java 32-bit vs. 64-bit. 我不相信问题是Java 32位与64位。
The problem could be Windows 32-bit vs. Windows 64-bit, however: 问题可能是Windows 32位与Windows 64位,但是:
ALSO: 也:
1) Please try running with this JVM option: 1)请尝试使用此JVM选项运行:
2) Please make sure you've installed the 64-bit version of Java 2)请确保您已安装64位版本的Java
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.