I have a console app that interacts with hardware. My idea was to log all exceptions with their stacktraces so valuable information is not lost due to not having a pipe to a file.
But how to handle the location of that file? I cant ask for a path each time.
That is why i thought just put the file next to the executable. But cant be sure where the app will reside. And I have not found a distinct answer to "how to get the app path"
I found: new java.io.File("").getAbsolutePath();
But no explanation how this works.
And: getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
But the op said this only may work.
Is there another way to handle the errorlogging / a sure way to get the app path?