I’m finishing my 3d dice extension and so I began restructuring my project. At the beginning, just to test if what I pretended was possible, I used what was the easier way for me to load images into the project, after some trials and I set up the following folder structure (notice I’m using the Maven set tutorial module as a template):
Project
|-src
|-target
|-classes
|-my_custom_component
|-myclass
|-images
|-sounds
So I have set the resources manually into the target directory. It worked as pretended, but was badly structured.
I then decided to place a resources folder in the root folder, configured to “Resource Root”. I then began getting the error reproduced below. Without the “Resource Root” configuration I don’t get the error, but even if I get the path right, the compiler doesn’t seem to recognize it and I get a null getResourceAsStream returns null. I tried removing the “Resource Root” and placing the resources folder within the src folder as follows:
Project
|-src
|-main
|-java
|-resources
|-images
|-sounds
|-target
|-classes
|-my_custom_components
which seems to be Maven standard. It seems to automatically recognize the folder as a resource folder and copy the resources to the target folder when we build, but I still get the error described below:
java.lang.ClassCastException: class sun.net.www.protocol.file.FileURLConnection cannot be cast to class java.net.JarURLConnection (sun.net.www.protocol.file.FileURLConnection and java.net.JarURLConnection are in module java.base of loader 'bootstrap')
at VASSAL.tools.icon.IconFactory.findJarIcons(IconFactory.java:376)
at VASSAL.tools.icon.IconFactory.initVassalIconFamilys(IconFactory.java:290)
at VASSAL.tools.icon.IconFactory.lambda$new$0(IconFactory.java:97)
at java.base/java.lang.Thread.run(Thread.java:833)
The project builds without error, but when I try to debug, by running vassal, it pops up. It seems to be related to how the folders are set up, since it doesn’t even invoke my class. Can someone point me to what may be causing this error. I’m really stuck here.
As an additional related question, less important for this moment: the compiler copies what is in the resources folder to the target/classes folder, but when I use the getResourceAsStream(“sounds/nameOfSound.wav”) command, it goes search the resource inside the my_custom_component folder instead. How can I configure the project so that the resources are copied to that last folder?