I've been trying to set the default java encoding character set from "windows-1252" to "UTF8" and its not working.
I've tried using java -Dfile.encoding=UTF8 and I get
Error: Could not find or load main class .encoding=UTF8
Caused by: java.lang.ClassNotFoundException: /encoding=UTF8
in the VS code terminal and that doesn't work. I've also tried set JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8 and that doesn't work either I literally get nothing and the default encoding isn't changed. The curious thing is I can do this on the windows command prompt and when entering java -version I am told the encoding is set to UTF8. However using Charset.defaultCharset() at the beginning of the program is telling me my encoding is set to "windows-1252".
file.encoding.Charset defaultCharset()depends on the JDK being used. For JDK 17 it "typically depends upon the locale and charset of the underlying operating system", but for JDK18+ the "default charset is UTF-8, unless changed in an implementation specific manner". So update your question to state which JDK you are using - that's essential information.