IDEA控制台中文乱码问题

  1. JDK17及以前:在Custom VM Options中增加
    -Dfile.encoding=UTF-8

  2. JDK18:在Run->Edit Configurations中增加VM Options:
    -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8

  3. JDK19到JDK21:在Run->Edit Configurations中增加VM Options:
    -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8

  4. 环境变量 JAVA_TOOL_OPTIONS 可以传递到子进程,解决套娃java进程乱码问题