[英]Eclipse not able to see javax package
我目前正在嘗試處理圖像,特別是將圖像從 JPEG、WEBP 和 BMP forms 轉換為 PNG forms,我的方法使用javax.imageio.ImageIO
class。 當我嘗試導入它時,Eclipse 大喊 package 該類型無法訪問。 我覺得這很奇怪,我自己去挖掘 StackOverflow,發現多個答案說我應該刪除並重新添加 JRE。 這沒有用,有點不足為奇,但是在查看我的構建路徑時,我注意到 JRE 缺少整個 javax package。 這可能是有原因的嗎? 有解決辦法嗎?
確切的錯誤是The type javax.imageio.ImageIO is not accessible
access 並且建議的編輯詢問我是否要在 package javax.imageio
中制作 class ImageIO
。
我正在使用最新版本的 Eclipse。 我的 JDK 是java-16-openjdk-amd64
。 我正在運行 Ubuntu 20.04。 我從頭開始構建這個應用程序,所以我沒有使用 Maven(除非 Eclipse 默認使用 Maven)。
我嘗試在我的命令行中編譯一個基本的 class 並且它出於某種原因工作,盡管它沒有在 Eclipse 中工作。
如果沒有必要,我寧願不要將我的 JDK 恢復到舊版本。
You do not call "new" on a static class To make an instance non static of it if it ever does have such a type available from one of its static methods you cast it to that type. 但是,使用 javax.imageio.ImageIO you make other classes from its methods
。
import java.awt.image.BufferedImage;
import java.io.*;
try{ // wrap in FileNotFoundException IOException
File input = new File("/somewhere/over/the/rainbow/cementplant.jpg");
//static classes are called directly with a method
BufferedImage bfi = (BufferedImage)javax.imageio.ImageIO.read(input);
原來我只是個白痴。 事實證明,我實際上是在沒有意識到的情況下用模塊制作的。 我所要做的就是擺脫模塊文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.