I'm writing an application that should be able to save a text file to any location. When I'm running the code in eclipse I get the following Exception:
java.io.FileNotFoundException: C:\myFile.txt (Zugriff verweigert)
"Zugriff verwiegert" is german for permission denied.
I can write to C:\Users\MyUser\Documents though.
I did some research and found out that the application needs administrator rights. If that is true, how can I run it as administrator in eclipse?
My code to write the file:
try {
PrintWriter writer = new PrintWriter("C:\\myFile.txt", "UTF-8");
writer.print(script.toString());
writer.close();
} catch (FileNotFoundException | UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Edit: Stackoverflow associates my question with the following one: How do I elevate my UAC permissions from Java? But I want to know if it is possible in eclipse! ;D