简体   繁体   English

Eclipse 无法看到 javax package

[英]Eclipse not able to see javax package

I'm currently trying to fiddle with images, specifically convert images from JPEG, WEBP, and BMP forms to PNG forms and my method uses the javax.imageio.ImageIO class.我目前正在尝试处理图像,特别是将图像从 JPEG、WEBP 和 BMP forms 转换为 PNG forms,我的方法使用javax.imageio.ImageIO class。 When I tried importing it, Eclipse yelled that the package that the type was not accessible.当我尝试导入它时,Eclipse 大喊 package 该类型无法访问。 I thought that was weird and went digging through StackOverflow on my own and found multiple answers saying I should remove and re-add the JRE.我觉得这很奇怪,我自己去挖掘 StackOverflow,发现多个答案说我应该删除并重新添加 JRE。 This didn't work, somewhat unsurprisingly, but while looking through my build path I noticed that the JRE was missing the entire javax package.这没有用,有点不足为奇,但是在查看我的构建路径时,我注意到 JRE 缺少整个 javax package。 Is there a reason this could be?这可能是有原因的吗? Is there a fix?有解决办法吗?

The exact error reads The type javax.imageio.ImageIO is not accessible and the suggested edits ask me if I want to make class ImageIO in package javax.imageio .确切的错误是The type javax.imageio.ImageIO is not accessible access 并且建议的编辑询问我是否要在 package javax.imageio中制作 class ImageIO

I am using the latest build of Eclipse.我正在使用最新版本的 Eclipse。 My JDK is java-16-openjdk-amd64 .我的 JDK 是java-16-openjdk-amd64 I am running Ubuntu 20.04.我正在运行 Ubuntu 20.04。 I built this app from the ground up, so I am not using Maven (unless Eclipse uses Maven by default).我从头开始构建这个应用程序,所以我没有使用 Maven(除非 Eclipse 默认使用 Maven)。

I tried compiling a basic class in my command line and it worked for some reason, despite not working in Eclipse.我尝试在我的命令行中编译一个基本的 class 并且它出于某种原因工作,尽管它没有在 Eclipse 中工作。

I would rather not revert my JDK to an older version if I don't have to.如果没有必要,我宁愿不要将我的 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. 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. However, with the javax.imageio.ImageIO you make other classes from its methods .但是,使用 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);

It turns out I was being just being an idiot.原来我只是个白痴。 It turns out I had actually made this with a module without realizing it.事实证明,我实际上是在没有意识到的情况下用模块制作的。 All it took for me was to get rid of the module file.我所要做的就是摆脱模块文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM