So geht ein minimaler HTTP-Request (GET) in Java 11:

import java.net.*;
import java.net.http.*;
import java.net.http.HttpResponse.*;

public class SimpleRequest {
    public static void main(String[] args) {
        var client = HttpClient.newHttpClient();
        var request = HttpRequest.newBuilder(
            URI.create("https://foo.bar")).build();

        try {
            var response = client.send(request, BodyHandlers.ofString());
            System.out.println(response);
        } catch (Exception e) {
            System.out.println("Error");
            e.getStackTrace();
        }
    }
}

Aufruf:

java request.java