1 回答

TA貢獻1909條經(jīng)驗 獲得超7個贊
不得不編輯我的答案,因為最后它工作了,但不正確,現(xiàn)在有了這個類,我可以正確看到 java fx 階段,但服務器停止正常工作,所以如果有人有更好的解決方案,我將很榮幸閱讀這個解決方案 :( .
public class Server extends Application {
private static Object lock = new Object();
private static ServerLog serverLog = new ServerLog();
public static void getService(Socket s) throws IOException { ... }
public static void main(String[] args){
launch(args);
new File("users").mkdir();
try {
ServerSocket socket = new ServerSocket(8189);
while(true) {
Socket s = socket.accept();
getService(s);
}
}catch(IOException e){e.printStackTrace();}
}
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("View/server.fxml"));
primaryStage.setScene(new Scene(root, 800, 600));
primaryStage.setTitle("Server Log");
primaryStage.show();
}
}
添加回答
舉報