import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpServer;
public class SimplestPossibleServer {
public static void main(String[] args) throws IOException {
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/", (e) -> {
byte[] response = "Hello, World!".getBytes();
e.sendResponseHeaders(200, response.length);
try (OutputStream os = e.getResponseBody()) {
os.write(response);
}
});
server.start();
}
}