I have a problem compiling simple blocking GET example from the HttpRequest JavaDoc:
package org.example; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import static java.net.http.HttpRequest.noBody; import static java.net.http.HttpResponse.asString; public class Http2 { public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException { HttpResponse response = HttpRequest .create(new URI("http://www.infoq.com")) .body(noBody()) .GET().response(); int responseCode = response.statusCode(); String responseBody = response.body(asString()); System.out.println(responseBody); } }
I'm getting package java.net.http does not exist
error when compiling using JDK 9:
Same error occurs using command line and IntelliJ.
It is not a problem with my module because classes without java.net.http compiles and run without any problem.
Any idea what is going on?