Environment Variable for project path

2
I have a custom Java Action that needs to load settings from a onfiguration file. I want to use a relative path to specify the location of the file so that anyone can download project from the team server and not have to change anything to run. The config file is located under the project folder. Mendix wants to use the Mendix install path as the starting location which wont work. Is there some env variable or other mechanism I can use tell it to look under the project folder?
asked
2 answers
4

As Michel suggested you should place all your resources (such as config files) in the resource folder. This keeps a nice and clean project folder and the modeler will automatically include all the files from the resource folder into your deployment archive.

Like you said the default working directory the runtime uses is kind of unpredictable. But you can ask the runtime the location of the resource folder to get the path to your config file

String pathToConfigFile = com.mendix.core.Core.getConfiguration().getResourcesPath().getAbsolutePath();
pathToConfigFile += "/MyConfigFile.config";
return pathToConfigFile;
answered
2

You should put such files in the resources folder. Then you can then use the configuration api to find the correct folder

answered