I have implemented a Java class that handles files of .txt-Format by relative paths. It works all well during execution in Eclipse. But if I’m executing the (unchanged) compiled file in the Java JRE outside of Eclipse, I’m getting a java.io.FileNotFoundException.
I implemented new File(".").getCanonicalPath()
and found the source of my problem:
Executed in Eclipse I get returned: C:\Users\xy\git\Project\Project
Executed in Java 8 JRE I get returned: C:\Users\xy\git\Project\Project\bin
I thought of a workaround, but handling two different code versions for development and deployment seems an unnecessary source of errors to me.
So my question is how to fix the problem. I would prefer a hint how to reconfigure Eclipse.
Thanks in advance Threx