Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a home-work to create a http server with java , a simple one and from scratch . After searching google and here ...i found this link "see the best response" with a very nice response ,so i copy/paste this example to eclipse , but it doesn't 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;

can you please help me so i can make eclipse recognize them? Also if isn't asking for to much do you know some other link with a HttpServer example? Thank you in advance !

like image 377
Andi Domi Avatar asked Oct 31 '12 10:10

Andi Domi


1 Answers

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

like image 126
Jmini Avatar answered Oct 05 '22 11:10

Jmini