I have the following Java code to create an HTML file. I use the j2html library for that:
String html = html(
                     head(
                         meta().attr("charset", "UTF-8"),
                         title("test"),
                         link().withRel("stylesheet").withHref("style.css")
                     ),
                     body(
                            h1("Räte"),
                            h2("Äpfel")
                     )
                   ).render();
File file = new File("index.html");
FileUtils.writeStringToFile(file, html);
This works perfectly if I launch the program via IntelliJ, and I get this output:
test
Räte
Äpfel
But if I create a JAR artifact and launch it, the umlauts aren't displayed correctly. It looks like this:
test
R�te
�pfel
It's the same Java code and the charset is set to UTF-8.
 
    