Pergunta

I need to send a request to the server to run a jar file with a string argument/parameter and return the results as a string.

Foi útil?

Solução

On server side you can run a process and send result back like this :

HttpServer.bind(InternetAddress.ANY_IP_V4, 3031).then((server) {
  server.listen((HttpRequest request) {
    var param = request.uri.queryParameters['name'];
    Process.run('java', ['-jar', 'myJar.jar', param]).then((pr) => 
        request.response
          ..write(pr.stdout)
          ..close()
    );
  });
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top