I have workspace where I save all my java projects worked in Eclipse.
Let's call it D:\Workspace\
. I have a project in said workspace which route lets say is: D:\Workspace\DoubleDotting\
.
In said Java project, in the main method, I create a file object in the following way:
File doubleDotted = new File("..\Folder1\file.xyz");
At the moment of exporting the program as a runnable Jar into D:\Projects\DoubleDotting\Folder2\
, the program executes just fine, for D:\Projects\DoubleDotting\Folder1\file.xyz
exists.
However file.xyz
does not exist in D:\Workspace\DoubleDotting\Folder1\
, so naturally when running/debugging the program from Eclipse, I get a FileNotFoundException
.
Working with relative paths, is an amazing time-saver when working on generic programs that can be applied to multiple directories with a similar working structure, however it's a headache to debug within Eclipse.
Is there a way to change a project's working directory virtually within Eclipse or is the lazy option of creating such folders/files within the Project directory, the only solution to running/debugging within eclipse?