Reputation: 5399
It seems to be really crazy, but I can't do anything with broken encoding in the console of my IntelliJ IDEA.
Things I made to overcome this:
-Dfile.encoding=UTF-8
and -Dfile.encoding=UTF-8
in both idea.exe.vmoptions
and idea64.exe.vmoptions
(I use 64 bit version though).-Dfile.encoding=UTF-8
and -Dfile.encoding=UTF-8
to run/debug configuration of my application.Having all these done, there is still no luck and symbols are not shown correctly in the console. I tried to debug the java.io.PrintStream#println(java.lang.String)
method and found out that System.out.textOut.out.se.cs
equals to windows-1251. No idea where this value is coming from.
This issue has been bothering me for a long time and I was unable to find anything in the web that could help me.
Upvotes: 50
Views: 67681
Reputation: 41
This helps me:
By default, IntelliJ IDEA uses the system encoding to view console output.
From jetbrains.com
Upvotes: 2
Reputation: 3161
If you use gradle you can just add
org.gradle.jvmargs=-Dfile.encoding=UTF-8
to your %userprofile%\\.gradle\gradle.properties
file (or gradle.properties
on project level).
Ref.: https://docs.gradle.org/current/userguide/common_caching_problems.html#system_file_encoding
Upvotes: 1
Reputation: 1
Polish letters (Polskie litery) I got with @Vadzim's tips:
1. Edit POM.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.22.2</version>
</dependency>
</dependencies>
</plugin>
2. Edit idea64.exe.vmoptions file by adding
-Didea.maven.surefire.disable.argLine=true
Upvotes: 0
Reputation: 21
The garbled characters have been resolved with the following settings. (IntelliJ IDEA Community 2022.2)
- Build, Execution, Deployment > Build Tools > Runner > Environment vairables.
- JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
Upvotes: 2
Reputation: 508
The only thing that worked for me is set environment variable JAVA_TOOLS_OPTIONS Run in win cmd
setx JAVA_TOOL_OPTIONS -Dfile.encoding=UTF8
And restart IDE.
Upvotes: 4
Reputation: 1
As @ogkasa mentioned, if you have such a problem and nothing helps, just try to install another JDK version. Me personally tried every possible solution but none worked. So i just rolled back to JDK 17 and now cyrillic (which was my problem) works properly.
Upvotes: 0
Reputation: 364
In Intelij coding java
console
System.out.println("Hà nội"); // unicode content
Using SDK amazon corretto version ... can help you println unicode console
Upvotes: 1
Reputation: 1
If anyone has come across this problem and nothing works on the top answer, try to download another JDK version and use at SDK.
Upvotes: 0
Reputation: 2188
IntelliJ IDEA uses the operating system's shell internally as the console. In Windows that's Command Prompt. So if adding...
-Dconsole.encoding=UTF-8
-Dfile.encoding=UTF-8
... to your VM Options under Help -> Edit Custom VM Options
doesn't help, ensure your shell supports UTF-8 characters in the first place.
Upvotes: 2
Reputation: 772
This works for me.
Upvotes: 58
Reputation: 26160
In my case, examining System.out.textOut.out.se.cs
in debug hinted that IDEA picked up maven surefire arguments for every JUnit Run Configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- force 7-bit default encoding to ensure that nothing depends on it -->
<argLine>-Dfile.encoding=ASCII</argLine>
</configuration>
</plugin>
I've resolved this by adding -Didea.maven.surefire.disable.argLine=true
to the idea64.exe.vmoptions file.
See also: https://www.jetbrains.com/help/idea/configuring-output-encoding.html.
Upvotes: 0
Reputation: 1944
You may have modified the wrong file,
not : C:\Program Files\JetBrains\IntelliJ IDEA xxxx\bin\idea64.exe.vmoptions
should be: C:\Users\USER_NAME\.IntelliJIdeaxxxx\config\idea64.exe.vmoptions
you can add both -Dfile.encoding=UTF-8
and -Dconsole.encoding=UTF-8
Upvotes: 13
Reputation: 1122
My theory is that your java class file are using "windows-1251" encoding, and you need to set it "UTF-8".
looks at the screenshots below.
To reset all files encoding, you can manually edit encodings.xml. You can change the default file encoding in settings dialog.
Upvotes: 5