我无法弄清楚出了什么问题!我试图运行一个简单的套接字通信。我正在使用Eclipse Mars 2,顺便说一句,它在调试模式下兑现并退出,当我尝试运行Junit测试时!我不知道为什么!
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x739ac3e1, pid=2144, tid=0x0000182c
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) Client VM (25.111-b14 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [chtbrkg.dll+0x1c3e1]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\User.ASUS\Documents\eclipse\workspace\Sockets\hs_err_pid2144.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
我在服务器上收到上面的错误消息,客户端上有java.util.NoSuchElementException!正是当我尝试从服务器获取结果时(temp = scanner2.nextInt();在Client.java中)
服务器类
package main;
import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
public class Server {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = new ServerSocket(1234);
System.out.println("Waiting for the client...");
Socket socket = serverSocket.accept();
System.out.println("Client connected");
Scanner scanner = new Scanner(socket.getInputStream());
int number = scanner.nextInt();
int temp = number * 2;
PrintStream printStream = new PrintStream(socket.getOutputStream());
printStream.println(temp);
}
}
客户端类
package main;
import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;
public class Client {
public static void main(String[] args) throws UnknownHostException, IOException {
int number, temp = 0;
Scanner scanner = new Scanner(System.in); // to read input from user
Socket socket = new Socket("127.0.0.1", 1234);
Scanner scanner2 = new Scanner(socket.getInputStream()); // used to accept results from the server
System.out.println("Enter any number");
number = scanner.nextInt();
PrintStream printStream = new PrintStream(socket.getOutputStream());
printStream.println(number); // send the number to the server
temp = scanner2.nextInt();
System.out.println(temp);
}
}
答案 0 :(得分:0)
崩溃发生在chtbrkg.dll
库中,该库不属于Java或Eclipse Mars或Windows。我真的不知道chtbrkg.dll
是什么(谷歌搜索表明它是AdSkip软件的一部分),但这显然是PC上第三方软件的问题。