Intellij can't find java.net.http when compiling with Java 11

In the case that the above proposed resolution (by @Will) does not solve your issue as was the case with me (i.e. setting the project language level), check to to see what the bytecode target version of your java compiler has been set to, in your project preferences: Set project preferences byte code version for java in IntelliJ


I had the wrong project language level set. To use java.net.http you need it to be at least 11. To change the project language level see: https://www.jetbrains.com/help/idea/project-page.html

Hopefully this helps someone else out.


I had the same problem with the package jdk.jfr. This is how I fixed it. It should work for you too.

In order to make it work I had to make 2 changes:

First I had to set the language level to 11; see in the picture below.

enter image description here

Then I had to adjust the Java Compiler. The Target bytecode version is 11 and I set the project bytecode version Same as language level. Then you don't have to change all of them constantly. Please see picture below.

enter image description here