Eclipse can not recognize the com.sun.net.httpserver.HttpServer package

I have homework to create an HTTP server with java, simple and from scratch. After google search and here ... I found this “see the best answer” link with a very nice answer, so I copy / paste this example to overshadow it, but it does not recognize the package

import com.sun.net.httpserver.Headers; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; 

Could you help me so that I can get eclipse to recognize them? Also, if you are not asking a lot to learn about any other link with an HttpServer example? Thank you in advance!

+10
java eclipse import package
Oct 31 '12 at 10:21
source share
5 answers

It should be available with JDK starting from version 1.6. Otherwise, you can add it to your buidpath separately. See the link below:

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

+3
31 Oct. '12 at 10:29
source

I had the same issue with Java 8.

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

You need to add the "Available" access rule for the com/sun/net/httpserver/** template:

Add access rule

Related question: Access restriction: not available due to the restriction on the required library. \ Jre \ lib \ rt.jar

+46
Sep 20 '14 at 5:52
source

I got the same issue on Mac OSX 10.8, Eclipse Kepler Service Release 2. I found that it depends on which JVM you are using. Changing Apple's JVM (default) to Oracle resolved the issue.

+2
Nov 16 '14 at 13:16
source

For any reason, are you using Java 5.0? Unfortunately, the jar is not bundled with the Java 5.0 SDK, and you will want to download the httpserver jar from this location and install it in your CLASSPATH.

0
Oct. 31 '12 at 10:26
source

The easiest solution for this is to go on to create the path configuration and change the default JRE from the MAC. Just remove the submitted one and add it from the Java installation path:

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

0
Jun 08 '19 at 12:55 on
source



All Articles