Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Java System Output Encoding

I have a problem with encoding of Java System Output occurring only in Visual Studio Code.

My program is very simple:

public class Main {
    public static void main(final String[] args) {
        System.out.println("Příliš žluťoučký kůň úpěl ďábelské ódy");
    }
}

but the output looks like this:

Příliš žluťoučký kůň úpěl ďábelské ódy�ábelské ódy�dy

My file has the UTF-8 encoding and it's being compiled with -Dfile.encoding=UTF-8 flag. I am using the official Java Extension Pack by Microsoft in Visual Studio Code.

like image 271
Orbit09 Avatar asked Jun 05 '26 02:06

Orbit09


1 Answers

for code runner extention,just add this code to user setting json:

"code-runner.executorMap":{"java": "cd $dir && javac -encoding utf-8 $fileName && java $fileNameWithoutExt",},
"code-runner.runInTerminal": true,
like image 60
Raofei Avatar answered Jun 06 '26 16:06

Raofei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!