Dear all,
For a custom module I am trying to set up some images to be loaded. I was expecting to have the images from dist folder automatically in the images folder, however, this does not seem to be the case, as it is putting them in the root folder.
Is there any way I can have them put in a separate images folder?
Thanks!
I’m assuming that you’re referring to the module template; if not, I’ll need more context to answer your question.
The contents of dist/
are copied into the root of the module. Images need to be in images/
inside the module, so should be put into dist/images/
if you’re using the module template to build your module.
Yes, it was the module template.
But then I am running into the same problem as in this:
java.lang.ClassCastException: class sun.net.www.protocol.file.FileURLConnection cannot be cast to class java.net.JarURLConnection - Development - Vassal (vassalengine.org)
And that is when the images is in the dist folder. Which is also created properly in the jar file and the target/classes/images folder.
And this is default code, nothing weird. And yet, it is crashing. Do you know any reason why? As far as I can see it it trying to create a complete folder as one connection, which could work I think, but why is the casting failing in this case?
I need more context. Can you show me the errorLog from a run with that error?
Are you running the module via Vassal, or running it under a debugger?
Either way, as Joel says, we would need the full error log to get the full context of what is happening.
2024-01-10 09:59:16,875 [10900-main] INFO VASSAL.launch.StartUp - Starting
2024-01-10 09:59:16,892 [10900-main] INFO VASSAL.launch.StartUp - OS Windows 10 10.0 amd64
2024-01-10 09:59:16,892 [10900-main] INFO VASSAL.launch.StartUp - Java version 21.0.1
2024-01-10 09:59:16,892 [10900-main] INFO VASSAL.launch.StartUp - Java home C:\Program Files\Java\jdk-21
2024-01-10 09:59:16,892 [10900-main] INFO VASSAL.launch.StartUp - VASSAL version 3.7.6
2024-01-10 09:59:16,893 [10900-main] INFO VASSAL.launch.Launcher - Player
2024-01-10 09:59:22,653 [10900-IconFactory-preload] ERROR VASSAL.tools.ErrorDialog -
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:1583)
So, from the docs ( JarURLConnection (Java Platform SE 8 ) (oracle.com)) I read that it expects a jar file connection, which is not the case for the images, which is a folder.
Update:
The images folder was the cause of this error I got, so inside dist/images to put images does not seem to work. But I would like to put default images somewhere. Anyone got any clue on how to do this the proper way, without causing the iconFamily to give an exception?
You must put the images in dist/images/
if they’re going to be put into the module produced by running mvn package
. If you don’t do this, the images will not end up in the module.
Anyway, the problem in your errorLog is not with the module images. The errorLog you posted shows an error loading Vassal’s own icons. This suggests that you’re not running the Player correctly. How are you running the Player?
So, I am having the most simple example I can think of. Downloaded the template again for the new module, pointed it to the latest version of the vassal source, added images to dist/images folder and thats it.
If you’re going to run the Player from an IDE, you need to tell the IDE where to find the resources in Vengine.jar. Somebody else here will have an idea of how; I can’t tell you that, as I don’t use an IDE myself.
Can you possibly explain to me how you would do this without an IDE?
I’d start Vassal normally and open the module using “Open Module”.
Why are you starting the Player from an IDE? (If the answer is: “Because you are using the IDE for debugging”, I can say that’s something I rarely ever do with module code, so you’ll need to get help from someone who uses an IDE for that.)
I would love to use the debugger, to gain more knowledge on certain parts of the booting and setting up of scertain parts of a module. But I will use your way for now to keep it simple. If however, someone know the way in IDE please let me know.
For now I found a correct workaround. I created a copy of the module, but without the images folder. In here I can do debugging. When everything works, I copy the code back into the original module code.
VASL’s Getting Started shows how to do this:
Basically:
In “Project Structure - Modules - Dependencies”, add the Vengine.jar item which is listed in the libraries: