본문으로 건너뛰기

GitHub Codespace에서 Java 버전 변경하기

2024년 9월 5일에 작성되었고, 블로그를 이전하며 옮겨온 포스트입니다.
여기에서 원본을 확인할 수 있습니다.

군대에서 개발 하려다..

군대 싸지방에서 개발 공부를 어떻게 할까 방법을 알아보던 중, GitHub Codespace으로 개발이 가능하다는 것을 알게되었다. 그래서 start.spring.io 에서 새로운 프로젝트를 만들고, 다운받은 프로젝트를 GitHub Codespace로 옮겼다. 그리고 잘 실행되나 프로젝트를 실행했더니 아래와 같은 오류를 만나게 되었다.

만난 오류

@yunh03 ➜ /workspaces/test (main) $ gradle --refresh-dependencies

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'example'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.3.3.
     Required by:
         root project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.3.3
      > Dependency requires at least JVM runtime version 17. This build uses a Java 11 JVM.

* Try:
> Run this build using a Java 17 or newer JVM.
> 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.
> Get more help at https://help.gradle.org.

왜 그랬을까?

오류 코드를 확인해 보니, GitHub Codespace에 자동으로 설치되어 있던 Java의 버전은 11이였고, 내가 생성한 프로젝트를 실행하려면 그 상위 버전인 Java 17이 필요했다. 그래서 정보를 찾다 보니, sdk명령어로 새로운 버전의 자바 설치, 자바 버전 변경이 가능하다는 것을 알게되었다.

해결하기

sdk install java 17.0.9-amzn
sdk default java 17.0.9-ms

마지막으로

아마.. 싸지방에서 개발 공부를 하게 되면서 원래 사용하던 inteliJ IDE를 벗어나 GitHub Codespace를 사용하게 되었기에 여러 오류와.. 불편한 상황들을 많이 맞이하게 될 것 같다. 개발 공부를 하면서 또 새로운 오류들을 만난다면 해결 과정, 방법을 공유하게 될 것 같다. 하.. 전역하고 싶다

출처

https://github.com/orgs/community/discussions/47246