What is the default folder used for load("config.file")? #7

meglio opened this Issue Feb 29, 2012 · 8 comments

2 participants


No description provided.


It's simply Java default directory. From javadoc java.io.File:

By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.

Now a free tip: You can directly get that value with Configrity:

 val currentDir = Configuration.systemProperties[String]("user.dir")

The currentDir variable will hold the default directory name.


Thanks, very valuable. I'm new to Java at all, that is why I ask such simple questions.
This is good that I can use systemProperties.
Can you recommend what is the best way to do for my scenario?

I have my deployment directory not related to the user home.

User home: /home/aoi
Deployment: /var/www/aoi/jetty_instance/webapps/root.war

Then I have start_prod.sh like this:


export port=$(expr $(cat base_port) + 0)

echo "Starting the 'production' Jetty process at port $port"

nohup java -Xmx$(cat ram_size) -Drun.mode=production -Djetty.port=$port -jar start.jar etc/jetty.xml >> logs/std.out 2>> logs/err.out &
echo $! > prod.pid
echo "The PID is $!"

So must I add something like -Daoi.distconf="/var/www/aoi/jetty_instance/dist.conf"

... and then something like this?

 val distConfig = Configuration.systemProperties[String]("aoi.distconf")



In that case you have to look in environment:

val distConfig = Configuration.environment[String]("aoi.distconf")

Another approach is to put the config file in the classpath and then access it as shown here:
https://github.com/paradigmatic/Configrity/wiki/InputOutput (look for "Loading from classpath")


Thanks, I'll try environment.
P.S. I do not know / do not understand what classpath is.


You will need to spend some time learning about Java basics to understand how the JVM works. For the classpath start with:



Thanks for your quick answers and links!
yes, I'm spending 10+ hours a day now to dive into Java/Scala word.


I just discovered that -Dxxx parameter can be retrieved with using:


(and not Configuration.environment)


Indeed. I'm sorry if you lost some time. I was sure that -D were treated as environement variables. Unfortunately Java has environment and system properties and it's very confusing to know which thing is where. Perhaps, I will provide an unique configuration which merges both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment