I am writing a file encryption program at the moment, and am having issues with how the file is stored.

When running the program in netbeans, everything works fine. However, when running the .jar file from the command line, or in explorer it does not.

I have worked out where the problem lies: When running the program from within netbeans, the file is made using a different encoding. Notepad++ tells me that when run from within netbeans, the character encoding is "ANSI as UTF-8", whereas when run standalone, the file is generated using "ANSI" (and shows extra characters as a result.)

Output was originally performed using

Java Code:
PrintStream fout = new PrintStream(filename);
but I changed it to

Java Code:
BufferedWriter fout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF8"));
but still the same result.

So how do I force the standalone .jar file to use UTF8 when the above isn't doing it?



tl;dr - How do I force standalone .jars to use UTF8 encoding on output when
Java Code:
BufferedWriter fout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "UTF8"));
doesn't work?