[JAVA] IntelliJ console is garbled during gradle project

Occurs in IntelliJ on Windows at home. The company uses IntelliJ in the same way, but it is converted properly.

Hoge.java


public class Hoge {
    public static void main(String[] args) {
        System.out.println("Ah ah");
    }
}

Execution result


Ah ah

Process completed with exit code 0

Information on those who work properly

I checked the setting relations of the person who can convert.

version information

image.png

IntelliJ settings

image.png

Custom VM

:.IdeaIC2019.1/config/idea64.exe.vmoptions


# Custom VM options (Generated by Pleiades Installer)
# See https://pleiades.io/pages/pleiades_jetbrains_manual.html
#-Xms128m
#-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Xverify:none
-javaagent:C:\Users\*******\.IdeaIC2019.1\config\jp.sourceforge.mergedoc.pleiades\pleiades.jar
-Dconsole.encoding=UTF-8
-Dfile.encoding=UTF-8

Things that look like configuration files

JetBrains\IntelliJ IDEA Community Edition 2019.1.2\bin\idea64.exe.vmoptions

:bin\idea64.exe.vmoptions


-Xms128m
-Xmx750m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djdk.http.auth.tunneling.disabledSchemes=""
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow

Find out

There is something suspicious in the user folder. C:\Users\*****\.IdeaIC2019.1\config

Consider deleting the cache. Qiita --How to clear the cache of IntelliJ Idea

Result of trying

You can't do this far. why? ?? ?? It's the same.

The build method was different

When I suddenly look at the console

> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
…

This was output. (I made this with the gradle project ... The company was a normal project ...)

When I tried google, I found the following site. How to specify character encoding in Gradle

Added the following to ** build.gradle **.

build.gradle


plugins {
    id 'java'
}

group 'com_tutorial'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/org.projectlombok/lombok
    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'

    testCompile group: 'junit', name: 'junit', version: '4.12'
}

//Describe the following line
tasks.withType(AbstractCompile)*.options*.encoding = tasks.withType(GroovyCompile)*.groovyOptions*.encoding = 'UTF-8'

bingo. Transformed!

Execution result


Ah ah

Process completed with exit code 0

Links that may be helpful

~~ After all, everything was different. ~~

3 points set when the Tomcat log of the console is garbled in IntelliJ IDEA https://qiita.com/qurage/items/cb57bb9c942e55ed06d1

About the cause of garbled characters in the console of intellij-idea https://ja.stackoverflow.com/questions/42721/intellij-idea%E3%81%AE%E3%82%B3%E3%83%B3%E3%82%BD%E3%83%BC%E3%83%AB%E3%81%A7%E3%81%AE%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91%E3%81%AE%E5%8E%9F%E5%9B%A0%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6

Official help https://pleiades.io/help/idea/configuring-individual-file-encoding.html

Recommended Posts

IntelliJ console is garbled during gradle project
What is Gradle?
[Java] [Play Framework] Until the project is started with Gradle