Gradle error: java_home is not set and no java command could be found in your path.

Develoment/Unity issue

[유니티] GPGS 플러그인 ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 해결법

Seo_re: 2021. 9. 12. 23:43


※ 해당 에러가나는 유니티 버전은 Hub에서 유니티 설치시, JDK를 같이 설치하는 버전부터이다.


구글 플레이 게임 서비스(이하 GPGS)를 연동하기위해 플러그인을 다운받아 유니티에 임포트를 하고 Resolve를 했는데, 난데없는 에러가 떴다.

Gradle failed to fetch dependencies.
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

'JAVA_HOME'이라는게 설정되지 않았다고한다.

찾아보니 최근 유니티들은 Hub에서 유니티 설치시, SDK, NDK, JDK를 다 설치하다보니 JAVA를 따로 설치할 필요가 없다. 문제는 여기서 발생하는데 GPGS 플러그인 설치 후, Resolve를 할 때 에러가 발생하는것이다.

에러를 추가로 읽어보면,

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

JAVA가 설치된 곳을 JAVA_HOME 변수와 일치시켜달라고 한다. 즉, JAVA_HOME이라는 환경변수를 설정해주면 된다.

그럼 시작해보자!

환경변수 설정

1. 내 컴퓨터에서 속성에 들어간다.

2. 고급 시스템설정 - 환경변수 버튼을 눌러준다.

Gradle error: java_home is not set and no java command could be found in your path.

3. 시스템 변수 - 새로 만들기 버튼을 눌러 다음과 같이 설정한다.

4. 변수 값에 OpenJDK의 경로를 넘겨준다

  ※ 경로 : 유니티 설치 경로\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK

Gradle error: java_home is not set and no java command could be found in your path.

여기까지 설정을 마쳤다면 이제 재부팅 후 다시 Resolve를 시도해보자!

Gradle error: java_home is not set and no java command could be found in your path.

그러면 Resolve가 진행되며 위와같이 정상적으로 성공 메세지를 받을 수 있다!

androidandroid-studioflutter

I installed Android Studio 4.1 and trying to run existing project. But it gives error like this:

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

Best Solution

You have to set the JAVA_HOME Environment Variable.

On Windows, I solved the issue as follows:

  1. Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused me an error that required me to downgrade.)

  2. Set the "JAVA_HOME" Environment Variable:

    • Open Windows Search, type in “env”, and choose “Edit the system environment variables”.

      Gradle error: java_home is not set and no java command could be found in your path.

    • Click on "Environment Variables...".

    • Click on "New".

    • Fill in the "variable name" field with "JAVA_HOME".

    • Fill in the "variable value" with the path to where Java is installed on your computer. (for me it was under "C:\Program Files\Java\<jdkversion>")

      Gradle error: java_home is not set and no java command could be found in your path.

    • Click "OK" and close all dialogs.

  3. Restart your IDE / Terminal. (do not skip this step)

안녕하세요!! 강의 보고 배우고 있는 학생입니다!!

gradlew.bat build 입력을 하면 gradlew.bat: command not found라는 문구가 뜨는데 왜 그런 걸까용,.,? 

1

Gradle error: java_home is not set and no java command could be found in your path.

안녕하세요. pdh4963님, 공식 서포터즈 David입니다.

.

빌드하실 때, ./gradlew.bat build 가 아니라 ./gradlew build 로 명령을 입력하셔야 합니다:)

.
감사합니다.

댓글

Gradle error: java_home is not set and no java command could be found in your path.

그렇게 입력하면

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the

location of your Java installation.라는 오류가 뜹니다,,,ㅜ

Gradle error: java_home is not set and no java command could be found in your path.

2

Gradle error: java_home is not set and no java command could be found in your path.

당연히 환경 변수에 JAVA_HOME 설정 완료하였고 명령 프롬프트에서 javac, javac -version 등을 입력하여 설치 완료된 것도 확인하였습니다,,

댓글

Gradle error: java_home is not set and no java command could be found in your path.

gradlew 파일이 위치한 곳에서 java -version, javac -version 명령을 실행하셨을 때 버전이 정상적으로 출력되시나요?

출력되신다면 캡쳐 부탁드립니다.

3

Gradle error: java_home is not set and no java command could be found in your path.

혹시 말씀하신 gradlew 파일이 위치한 부분이 hello-spring 이 부분이 맞나요?? 일단 그 위치에서 java -version 했을 경우의 출력입니다!!

댓글

4

Gradle error: java_home is not set and no java command could be found in your path.

아 ㄱ리고 명령 프롬프트에서 gradlew build 입력했을 경우에는

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-11.0.13\bin

Please set the JAVA_HOME variable in your environment to match the

location of your Java installation.라는 오류가 뜹니다!!

(위에 댓글에 쓴 오류는 터미널로 실행했을 경우에 뜨는 오류입니다)

댓글

Gradle error: java_home is not set and no java command could be found in your path.

5

Gradle error: java_home is not set and no java command could be found in your path.

감사합니다!! 해결되었습니다

근데 cmd에서는 성공적으로 출력이 되는데 터미널에서는 오류가 뜹니다,, 혹시 이유가 뭔지 알 수 있을까요??

(혹시 몰라 gradlew build, ./gradlew build 둘 다 해봤습니다)

Gradle error: java_home is not set and no java command could be found in your path.

댓글

Gradle error: java_home is not set and no java command could be found in your path.

terminal에 환경변수 세팅이 안 되어 있어서 그럴 수 있습니다.

리눅스 환경에서 환경변수를 세팅하는 방법을 찾아보시고 JAVA_HOME을 세팅해주시면 됩니다.

6

Gradle error: java_home is not set and no java command could be found in your path.

계속 질문하는데도 친절하게 답변해주셔서 감사합니다!!

좋은 하루 보내세요!!

댓글