Im trying to use the HttpServer Class from com.sun package but i can't import it. It keeps saying: "The package com.sun is not accessible."
I've tried every solution i could find in other questions about this topic. I've added a rule to have access to it to my libraries. I changed my JDK to another installed JDK17. I don't know what to do anymore. It's for my college homework, so it would be cool to get it running.
Does someone have a clue?
my code problem:
the access rule:
my current used jdk:
You have a module-info.java
so you are using Java modules. Consequently you need to say that you are using the jdk.httpserver
module which contains com.sun.net.httpserver.HttpServer
.
You do that by adding the line:
requires jdk.httpserver;
to your module-info.java. So something like:
module modulename
{
requires jdk.httpserver;
}
where modulename
is the name of your module.
Alternatively delete the module-info.java
file to stop using the module system.