myeclipse 項目引入 com.sun.image.codec.jpeg 的api報錯解決方法

今天在作壓縮圖片的功能的時候發現JDK自帶的jar找不到的問題,網上找到一個方法,實測可行,這邊記錄下:ui


在Eclipse中處理圖片,須要引入兩個包:spa

  1.  
    import com.sun.image.codec.jpeg.JPEGCodec;
  2.  
    import com.sun.image.codec.jpeg.JPEGImageEncoder;

報錯:rest

Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library C:\Java\jre1.6.0_07\lib\rt.jar

此時解決辦法: 
Eclipse默認把這些受訪問限制的API設成了ERROR。 
只要把Windows-Preferences-Java-Complicer-Errors/Warnings裏面的Deprecated and restricted API中的Forbidden references(access rules)選爲Warning就能夠編譯經過。code

相關文章
相關標籤/搜索