这是我使用的代码片段:
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://www.google.com")).GET().build();
HttpResponse.BodyHandler responseBodyHandler = HttpResponse.BodyHandler.asString();
HttpResponse response = client.send(request, responseBodyHandler);
System.out.println("Status code = " + response.statusCode());
String body = response.body().toString();
System.out.println(body);
当我运行上面的代码时, Eclipse 会抛出NoClassDefFoundError
HttpClient。但是当我将jshell与--add-modules=jdk.incubator.httpclient
. 可以做些什么来使代码通过 Eclipse 执行?