Reputation: 85
I was trying to import HttpClient class in my code from java.net.http package. Turns out, this package is not present when I try to import.
I did some research and found that java.net.http was included from JDK 9 onwards. I have JDK 15 installed in my system but still I can't import this package.
IDE: Eclipse JDK: 15.0.2 JRE: 1.8.281
Installed JRE's JDK Compliance Level
Could someone help me with this issue?
Thanks, Ishan Pathak
Upvotes: 1
Views: 900
Reputation: 338835
The HttpClient
class was added to Java 11 and later.
You will need to configure your project within your IDE to compile for Java 11 or later. And you’ll need to configure your IDE to run with Java 11 or later when running your code.
I don’t know what you meant by JRE of Java 8 in addition to Java 15. You may have multiple versions of Java installed. That is okay, but you have to tell your IDE which one to use for your project.
Configuring for all the major IDEs ( IntelliJ, NetBeans, Eclipse ) has been covered many times already on Stack Overflow. So search to learn more. For example, here.
To learn more about the new HttpClient classes, see these posts on the OpenJDK.java.net site.
Upvotes: 1