gpt4 book ai didi

java - 错误: Java Virtual Machine Launcher.找不到主类

转载 作者:行者123 更新时间:2023-12-02 06:09:45 26 4
gpt4 key购买 nike

我的程序运行完美。但是,突然log cat 中开始出现许多错误。重新启动 Eclipse 后,我无法运行该程序。

它显示的错误是:Java 虚拟机启动器。找不到主类:服务器。程序将退出。

只有这个程序没有运行。我能够运行所有其他项目和程序。

public class server {

private static ServerSocket serverSocket;
private static Socket clientSocket;
private static InputStreamReader inputStreamReader;
private static BufferedReader bufferedReader;
private static String message;

public static void main(String[] args) {

try {
serverSocket = new ServerSocket(4444); //Server socket

} catch (IOException e) {
System.out.println("Could not listen on port: 4444");
}

System.out.println("Server started. Listening to the port 4444");

while (true) {
try {

clientSocket = serverSocket.accept(); //accept the client connection
inputStreamReader = new InputStreamReader(clientSocket.getInputStream());
bufferedReader = new BufferedReader(inputStreamReader); //get the client message
message = bufferedReader.readLine();

System.out.println(message);
inputStreamReader.close();
clientSocket.close();

} catch (IOException ex) {
System.out.println("Problem in message reading");
}
}

}
}

最佳答案

没有类Server,因为您的类名为server

public class server {
...

类名应始终以大写字母开头。比使用CamelCase 。这是常见的命名约定

关于java - 错误: Java Virtual Machine Launcher.找不到主类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21989842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com