I'm having a very uncomfortable problem. Generate a test JAR executable file, and it is generating the following error:
Exception en thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: URI is not hierarchical
at java.io.File.<init>(Unknown Source)
at Trivia.Interfaz.<init>(Interfaz.java:74) <= mi codigo
Starting with the internal scheme of my project. The images of the program I have saved as separate packages.
It is called "assets" the package where I have the images.
Well, in the code when I upload the images I have it written as follows:
Image img = ImageIO.read(new File(getClass().getResource("/assets/panama-16.png").toURI()));
Doing it this way, it does not give any type of error and the program runs normally in the IDE of netbeans, but the problem starts when I generate the executable JAR. And I read that this is caused by the reason that when generating the executable, Netbeans what it does is compress all those files (ZIP), and of course, already with that things change drastically in terms of the use of the URL .
My question is: How can I make from the JAR file to run all these images normally inside some package of the project without any problem?