Home > Net >  How to run GUI from Server with Client
How to run GUI from Server with Client

Time:11-04

Hello guys i made Battleship GUI on the Server, i can connect with the client but how can i run the GUI Apllication which is on the server with the client ?

Dont know how to tackle this problem

CodePudding user response:

The client needs to download the GUI Application as a jar file and then run it.

    URL website = new URL("http://www.mywebsite.com/gui-application.jar");
    Path path = Paths.get("gui-application.jar");
    try (InputStream in = website.openStream()) {
        Files.copy(in, path, StandardCopyOption.REPLACE_EXISTING);
    }

    ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", path.toAbsolutePath().toString());
    Process guiApplication = processBuilder.start();
  • Related