cleanUrl: /posts/convert-java-version-in-intellij

이번 프로젝트에서 처음으로 Java11을 사용하기로 했다. 팀에서 계속 Java8 버젼만 사용하다가 새로운 프로젝트를 만들려고 보니 Java11, Java15 버젼도 있는데 8 버젼만 사용하는게 좀 이상했다. Java 11로 넘어오면서 달라진 차이점은 조만간 정리할 예정이다.

일단 자바 버젼을 변경하고 IntelliJ 를 실행하니

Execution failed for task ':compileJava'.
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b061653a-0b72-48a9-9da2-92cd3687992b/20210127_095247.png

이러한 에러가 발생했다. Java SE 11 이 target 인데 JDK8 버젼으로 수행할 수 없다. 당연한 이야기지

IntelliJ 에서 한군데 수정하니 문제 없이 실행된다.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4cc374d0-d5de-43bf-902b-77cec85a472c/Untitled.png

File → Settings → Build, Execution, Deployment → Build Tools → Gradle 에서

Gradle JVM 이 Java8 로 되어있다. IntelliJ 문서에 보면 이 필드의 기본값은 프로젝트의 JDK 를 따라간다고 되어 있는데 왜 Java8 로 되어있는건지...

이 이외에도 자바 버젼을 선택하는 부분이 있다.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9d492d05-53ee-485d-bf70-c920b7957fc8/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/843372d1-94ea-43ae-9f4b-3bc492501448/Untitled.png