Categories
java

com.sun.net.httpserver.httpexchange not found in eclipse

In this post we will learn about com.sun.net.httpserver.httpexchange not found in eclipse

While I am trying to add Http Server in Core java application I faced below exception

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

If you are not to able to add above dependencies in java code, please verify below points

  • You should use java version above 1.6
  • Make sure you have configured correct JDK in your build path

If above things are correct still you are facing the issue means you need to do below thing in eclipse

you need to add com/sun/net/httpserver/ package in the access rule

  • Open Eclipse
  • Navigate to java build path
  • Click on the access rule under JRE System Libray
  • Click on the edit button and add an access rule like below image
Reference

https://stackoverflow.com/questions/13155734/eclipse-cant-recognize-com-sun-net-httpserver-httpserver-package

Related Articles

add rest service in core java application

Leave a Reply

Your email address will not be published. Required fields are marked *