{ How to define the JAVA_HOME Environment Variable } Android Applications on Unity or Android Studio

preview_player
Показать описание
When trying to export a Unity project for Android I got an error saying that the JAVA_HOME variable was not defined or did not point to a valid path.

How to check if the JAVA_HOME environment variable is defined

1. In the Windows search bar type "cmd" and open the Windows console
2. Write "echo %JAVA_HOME%"
3. If the result is the Java JDK path, the environment variable is defined, if the result is "%JAVA_HOME%" the environment variable is not defined.

How to define the JAVA_HOME environment variable:

1. In the Windows search bar write "environment", enter the option "Edit the system environment variables".
2. In the pop-up window, click on the "Environment Variables" button.
3. In the "System Variables" window click on New.
4. In the pop-up window, in the name of the variable write "JAVA_HOME". In the value of the variable we give the installation path of the Java JDK, by default it is: "C:\Program Files\Java\jdk1.8.0_191", but it will depend on the version of the JDK and the language of the operating system. We give OK to everything and with that we define the environment variable JAVA_HOME.

____________________________________________________________
*LINKS*

____________________________________________________________

#EN
Рекомендации по теме
Комментарии
Автор

If using the inbuilt install of JDK do you still need to set the E variables?

paranormalgamesstudios
Автор

In Unity, I want to implement Google AdMob Ads, so for that I installed the Google package and then it is required to resolve the external dependencies. But in my case it is failing. The error shows that
"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."

I have already set the JAVA_HOME in environment variable. Do you know how to solve this?

jesalonboard
Автор

Simple solution (If you downloaded the JDK):
In Unity Click on "Edit" > "Preferences" and uncheck JDK, SDK and NDK path and paste your own path, in my case it's:
JDK>> C:Program Files\Android\Android Studio\jre
SDK>> C:Program Files\AndroidSDK
NDK>> C:Program Files\Android\Android Studio\jre

yishayyosef