-
Notifications
You must be signed in to change notification settings - Fork 343
Description
I encountered some problems when developing imagej plugin.
Here is my code:
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(imageData);
BufferedImage bufferedImage = ImageIO.read(byteArrayInputStream);
ImageProcessor imageProcessor = new ij.process.ByteProcessor(bufferedImage);
ImagePlus img = new ImagePlus("Loaded Image", imageProcessor);
When I call it in IDEA, there is no problem. javax.imageio.ImageIO should be part of the java basic library.
But when I package it into a jar package and call it in plugins, an error occurs:
java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIO
This problem has troubled me for a long time. I have tried many methods but couldn't avoid it. Even putting a basic Java package rt.jar in various locations didn't work.
My purpose is just to build ImagePlus through ByteArrayInputStream. My requirement is to build an image from data transmitted through a network stream, while most tutorials are about reading local files.
My environment is as follows:
java.version: 1.8.0_322
IJ.getVersion: 2.16.0/1.54g
IJ.javaVersion: 8
I hope someone can help me solve this problem.