I want to create a Java class that I use to export images. This class will be exported in .JAR
file which will allow me to integrate it directly into another project by passing as input parameter the name of the file and in return I would have this image in PNG
format.
That's what I tried:
package militarySymbolsLibrary;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MainEntry {
public static void main(String agrs[]) {
}
public static BufferedImage generateImage(String symbolCode) {
File imageFile = new File("/pictures/SSGPU-------.png");
BufferedImage image;
try {
image = ImageIO.read(imageFile);
} catch (IOException e) {
image = null;
e.printStackTrace();
}
return image;
}
}
Pictures are stocked in folder pictures like this treeview below:
src
MainEntry.java
pictures
SSGPU-------.png
Then I export this class in .JAR
file, I add it to my other program, I pass a parameter (picture's name except for this test) and normally my class return PNG
file. But I have an error telling me that the file path is not the rigth one.
How can I solve this problem?
Thank you