I’ve thought of a similar solution, but this does not eliminate the fact that each developer MUST set it’s own path. The thing is, that this folder that I am trying to load will be located outside the cuba app. The solution that I am looking for should provide the following facilities. Having the app deployed as an UberJar in this path: /a/random/unix/system/path, I want my application to figure out that at the same path (/a/random/unix/system/path), there is a /resource folder in which there are some vital info.
Let’s say this is the file tree for my example:
- app.jar (the UberJar)
I would like that my UberJar will know that in the same folder with it, there will be this folder. This allows me to move the 2 files (app.jar and resources) in any folder in the system and as long as they are in the same folder, everything should be good.
PS: My current implementation is giving the relative path to the class in which I am using the /resource folder, but this is an ugly approach.
Instead of getting the path like this:
String pathToRes = "../../../resources"; // this is how I do it now
I would like to get it something like this:
String pathToRes = obj.getResource("logo.jpg");
Where obj already knows the absolute path to the /resources folder and searches for that resource that I need i.e. “logo.jpg”. I need obj to not be initialised with a hardcoded absolute path, instead, I would like to be initialised accordingly, to the location of the UberJar. I need this initialisation to be independent of the fact that the UberJar and /resources folder might be moved. At runtime, obj should contain the absolute path to the location of the UberJar.