When your Java application runs on CloudFoundry, it's running in a remote Linux container. It does not have access to your local file system and any files you reference need to be within the Linux container's filesystem, thus no c:\
Windows-style paths are going to work.
Your application, when running on CF, lives in the /home/vcap/app
directory (there's also a symlink at /app
which points to /home/vcap/app
that you can use if you want).
In addition, your application will be executed out of the /home/vcap/app
directory so the current working directory will be /home/vcap/app
.
Thus, if you need to reference files you can either reference them relative to the /home/vcap/app
directory or you can prefix the /home/vcap/app
to all paths and use a full path to the file.
If you don't like the idea of hard-coding /home/vcap/app
into your application, you can fetch this directory dynamically by looking at the HOME
environment variable. When your application runs, the HOME
env variable points to /home/vcap/app
.