Skip to content

JAVA_HOME is not set and no ‘java’ command could be found in your PATH

  • Gaz 

Are you tired of encountering the dreaded “JAVA_HOME is not set and no ‘java’ command could be found in your PATH” error when building your Unity project with the Google AdMob (or other) library included? Look no further! After extensive testing and research, I have found two simple solutions to this frustrating issue.

Option 1: A Unity bug?

I stumbled upon a supposed bug in Unity where the “JDK installed with Unity (recommended)” option is selected by default but ignored. To fix this, simply click the “Copy Path” button, uncheck “JDK installed with Unity” within the External Tools options in Preferences, and then paste the path back in. Voila! Successful builds until your next Unity restart.

External Tools panel in Unity Preferences

Option 2: Environmental variables to the rescue!

If option 1 doesn’t work for you, another solution is to create a new environmental variable called “JAVA_HOME” and populate it with the JDK path for the version of the JDK installed with Unity. To do this, copy the path from External Tools and paste it into a new environmental variable. Then, follow these steps:

Click Start and search for “system environment variables” and select the option that appears.

Searching for “System Environment Variables” in the Windows 11 Start Menu

Click on the Environment Variables button and then click “New” under “System Variables”.

Creating a new System Variable called JAVA_HOME

Enter the “Variable Name” as “JAVA_HOME” and the “Variable Value” as the JDK path you copied from External Tools.

Click OK on all of the open windows.

With these easy steps, you’ll be able to build your game successfully and get back to designing and developing. Say goodbye to the “JAVA_HOME is not set and no ‘java’ command could be found in your PATH” error for good!

Leave a Reply

Your email address will not be published. Required fields are marked *