Eclipse cant recognize com.sun.net.httpserver.HttpServer package

It should be available with JDK from 1.6 onwards. Otherwise, you can add it your buidpath separately. Refer below link:

How to download com.sun.net.httpserver package?


I hit same Issue on Mac OSX 10.8, Eclipse Kepler Service Release 2. I found that it is depends what JVM you use. Changing JVM from Apple(Default) to Oracle resolved the issue.


I had the same problem with Java 8.

com.sun.net.httpserver is not API (there is an access restriction, and Eclipse indicate this as error).

You need to add an access rule "Accessible" for the pattern com/sun/net/httpserver/**:

Add Access Rule

Related question: Access restriction: Is not accessible due to restriction on required library ..\jre\lib\rt.jar