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

ε祈祈猫儿з 提交于 2019-11-30 12:47:51
A.G.

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?

Jmini

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/**:

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

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.

By any chance, are you using Java 5.0? Unfortunately, the jar doesn't come bundled with a Java 5.0 SDK and you would want to download the httpserver jar from this location and set it in your classpath.

The simplest solution for this is to go to build path configuration and change the JRE from the default MAC. Simply remove the one presented and add the one from your java installation path, for example:

Library/Java/JavaCirtualMachines/jdk.1.8.0_191.jdk/Contents/Home/bin

When addding new JREs choose Standard VM instead of MacOS X VM

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!