java.net.http import - not found

450 Views Asked by At

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?

1

There are 1 best solutions below

0
Mirek Pluta On

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: