1

I am working in Intellij with Java 11. I want to use import java.net.http.httpclient in my project but the import statement is not found.

Background:

I am compiling on my Windows 10 Workstation to build for deployment on a Rasp Pi Zero W. The version of Java that I am using (SDK) is Azul Java 11.0.13.

When I type in import java.net.http.httpclient java.net is found but the http is not.

I have setup Intellij to use Java 11 AFAIK.

enter image description here

enter image description here

enter image description here

How do I get the import to work?

Al Grant
  • 2,102
  • 1
  • 26
  • 49

1 Answers1

3

Starting with java 9 if project has module-info.java that's the place were all non-default modules should be declared so that they can be used.

In your case it'd look as follows:

module ModuleName {
    requires java.net.http;
}

For more details you could read:

Mirek Pluta
  • 7,883
  • 1
  • 32
  • 23