Which Java imports should I use for I can use HttpClient and HttpRequest etc.?

I’m developing a component for synchronized http requests using e.g.

var client = HttpClient.newHttpClient();

but I coudln’t find which imports are suitable for this.

import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

don’t compile here in niotron IDE…

Thanks for any advice.

This is not how you create a new variable in Java. Statements declaring the class name do not start with var (that is JavaScript), you should use this:

HttpClient client = HttpClient.newHttpClient();

Also, if you are getting requests, you should use this code because it works asynchronously. (coutesy @Kumar)