When you run a Java project in eclipse, the current working directory is the root folder of the project. So why not just create your resource folder there?
ProjectDirectory
../bin
../src
../resourceDirectory
Then, in your project, you can fetch resourceDirectory
with
public File getDirectory(String dir) {
File cwdir = new File(".").getParentFile(); // remove the "." in path
for (File f : cwdir.listFiles()) {
if (f.isDirectory() && f.getName().equals(dir)) {
return f;
}
}
return null;
}
and
File resourceDir = getDirectory("resourceDirectory");
if (null == resourceDir) {
System.err.println("Resource directory not found");
System.exit(-1);
}
Note : you might perhaps want to create an utility class for the getDirectory()
method, or something similar. This is just an example.
Bottom line is that the application will most likely be launched where it should be and you might just use a startup file (.bat, .sh, etc.) to do that anyway. There is no need of putting resource directories inside your source or binary folder; keep them separated.