Java 9 no class definition exception

后端 未结 3 1368
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 00:57

So i want to try the http client

package com.company;

import jdk.incubator.http.HttpClient;

public class Main {

public static void main(String[] args) {
          


        
3条回答
  •  庸人自扰
    2020-12-19 01:24

    works fine for me if I use --add-modules jdk.incubator.httpclient as the start-up parameter.

    HttpClient client = HttpClient.newHttpClient();
    client.executor().execute(() -> System.out.println("Here")); // prints Here
    

    If you say that your module requires it, does not mean it will be included; at it is not included by default.

提交回复
热议问题