I am not convinced that it gives me all possibilities for my problem 1) xso said it was not a good answer 2) I would like to find an easiest solution 3) I doesn't address my question why browse the files in a jar has to be different as browse the files in the file system 4) it is an old thread, maybe it changed in Java 8 or Java 9 or in another library ?
even the new link doesn't convince me. Where is addressed the problem to find directories in directories ? Here it is only files in the jar. In my case, I don't know (and I don't want to know) the list of animals, the list of colors,...
I am developing games for eye-trackers (http://gazeplay.net). These games are done in particular for disabled children and their parents are often not accustomed to use computers. Hence, I try to release a software as easy as possible to run.
I have made it with java/javafx. My soft has to be downloaded as a jar and double clicked.
In a new game, the idea is to show some pictures to the child, a voice gives the order and (s)he stare at the correct one. For instance, « Where is the elephant ? » and the child has to select the elephant. It can be the same with colors, cartoon characters,… I tried to do something as generic as possible hence for animals, all are ordered in an « animals » directory where there is a directory for each animal (one for horses, one for eagles,…) and in each directory several images. It is hence easy to add a new animal (just need to add a directory) and easy to add a new picture (add it to the directory). It is easy to make a new game, build a new hierarchy of directories (one for colors, one for cartoon characters,…). Here is an excerpt of my actual directory structure.
It works pretty well in my IDE but unfortunately it doesn’t work in my jar. It seems easy to show an image if you know its complete path but impossible to use functions as File listFiles(). I try to find solutions but they don’t seem to work. Some people seem to say that is it is possible with nio but I was not able to make it works.
I have two questions : is it possible and if no, why is it impossible ? Folders exist in my jar, they don’t disappear, why is there no way to list their content ? If no, how can I implement a solution as easy as possible ?
Thank you !