목차
JAVA18로 오면서 표준 Java API의 default charset이 UTF-8로 지정되었습니다.(https://openjdk.org/jeps/400)
UTF-8가 표준 Java API의 default가 되지만, console I/O는 제외됩니다.
Intellij의 console 설정을 UTF-8로 한 들, PrintStream(우리가 console에서 사용하는 스트림 ex. System.out)은
UTF-8로 설정되지 못한 것 입니다. (한글 Windows의 console 인코딩은 default로 cp949를 사용합니다.)
그래서 VM Option에 표준 output의 charset을 새로 정의해줌
[해결 방법1. 실행 시 VM 옵션으로 추가하기]
Step1. JVM 콘솔 인코딩 옵션 추가
Intellij 우측 상단에서 Edit Configurations 선택
Step2. Add VM Options 클릭
Modify options - ADD VM options 선택
Step3. 옵션 명시
-Dfile.encoding="UTF-8" -Dsun.stderr.encoding="UTF-8" -Dsun.stdout.encoding="UTF-8"
옵션 추가
[해결 방법2. 시스템 변수로 설정하기]
Step1. Edit Custom VM Options 열기
Help - Edit Custom VM Options 선택
Step2. 옵션 추가
-Dfile.encoding=UTF-8
-Dsun.stdout.encoding=UTF-8
-Dsun.stderr.encoding=UTF-8
Step3. Intellij 재시작
Intellij를 재시작 한다.
[참조]
https://unagi-zoso.tistory.com/109
[JAVA] Intellij JDK 한글 깨짐 (Open JDK18 이전, 이후 나눔)
사건 발단 '본 글은 windows10 환경에서 Intellij를 사용하며 겪었던 한글 깨짐 문제의 회고입니다.' Intellij를 사용하는데 openJDK 18 버전을 깔고나서 뭔 짓을 해도 콘솔에서 한글 출력이 (UTF-8 인코딩)
unagi-zoso.tistory.com
'개발환경 세팅 > Intellij' 카테고리의 다른 글
visualVM 사용하여 프로파일링 하기 (0) | 2024.08.28 |
---|