Can not use the com.sun.net.HTTPServer.httpserver

不打扰是莪最后的温柔 提交于 2019-12-07 16:16:55

问题


I am using Eclipse Indigo and Java jdk7.

I'd like to create a litte webserver, but I am not able to use sun's webserver.

When I type:

{
 com.sun.net.httpserver.httpserver server;
}

I get the following Eclipse-Error-Message:

Description Resource    Path    Location    Type
Access restriction: The type HttpServer is not accessible due to restriction
    on required library C:\jdk1.7.0\jre\lib\rt.jar
Server.java /REST-Server/src/com/test/restserver    line 7  Java Problem

What am I doing wrong here? I do not have to include any other jar? Do I?


回答1:


You shouldn't use Sun's internal packages since they can be not present in other VM's. If you're sure you won't use other VM then Sun's/Oracle's, you can disable this warning in Project properties -> Java Compiler -> Errors/Warnings -> Deprecated and restricted API



来源:https://stackoverflow.com/questions/9579970/can-not-use-the-com-sun-net-httpserver-httpserver

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