Search Unity

Bug JAVA_HOME is not set and no 'java' command could be found in your PATH

Discussion in 'Android' started by Stranger-Games, Sep 5, 2019.

  1. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    I'm using the JDK and android sdk installed with unity but the player settings of android never open.
    upload_2019-9-5_16-52-20.png

    I always get the following errors.

    I tried to set manually JAVA_HOME and PATH to 'C:/dev/Unity/Installations/2019.2.2f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows' and 'C:/dev/Unity/Installations/2019.2.2f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows\bin' in my computer's environment settings, but I'm still getting the same error.
    I tried running C:/dev/Unity/Installations/2019.2.2f1/Editor/Data/PlaybackEngines/AndroidPlayer/SDK\tools\bin\sdkmanager.bat --list from cmd and it ran without problems.

    Thanks for advance.
     
    PsijicNine, leandrovtd and hopetolive like this.
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Try unselecting and selectingagain the JDK checkbox.
     
  3. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thank you for your reply.
    I tried that. I also tried to manually point to the JDK path C:/dev/Unity/Installations/2019.2.2f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows in the preferences, but I got the same weird error.

    Upgrading to 2019.2.3f1 fixed the problem however.
     
    hopetolive likes this.
  4. Austin_Hey

    Austin_Hey

    Joined:
    Nov 13, 2016
    Posts:
    4
    Oh my god... It was just as simple as that... I spent lot of time trying to figure out what was wrong...
    Had this issue suddenly on unity 2019.3.13f1 (it was working and the day after it wasn't).

    anyway it's fixed now ! thx for the tips ;)
     
  5. elifzaman111

    elifzaman111

    Joined:
    May 24, 2020
    Posts:
    1
    Hi I had the same error but i did not get your solution please?I will be very happy if you share. Thank you.
     
    electr1on likes this.
  6. electr1on

    electr1on

    Joined:
    Mar 21, 2018
    Posts:
    28
    +1
     
  7. Deleted User

    Deleted User

    Guest

    Uncheck jdk checkbox and paste jdk path manually:
    C:\Program Files\2019.1.7f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\OpenJDK\Windows\
     
  8. HectorOfPriamos

    HectorOfPriamos

    Joined:
    Jul 9, 2017
    Posts:
    15
    Hi everyone, I have unchecked the box, closed preferences window then opened it again and checked the box. In that way it worked for me
    However it's strange to have such an unsual solution :) I think it's that restarting thing with computers :)
     
  9. HectorOfPriamos

    HectorOfPriamos

    Joined:
    Jul 9, 2017
    Posts:
    15
    Once again hi everyone, strangely today I had the same issue again. Although the automatically set path is correct, I did as playpes16 said and this time it worked. The path I pasted was the same as the automatically set one but this time Unity wanted in that way I guess :)
     
  10. qleb1984

    qleb1984

    Joined:
    Aug 15, 2018
    Posts:
    15
    Worked for me too uncheck/check
     
  11. MoodyBulldog

    MoodyBulldog

    Joined:
    Jan 15, 2020
    Posts:
    1
    Hi All,
    Had the exact same problem, working one day failed the next. This happened after a windows update, which I suspect may have caused the issue. Anyway, my fix was to select browse on JDK & SDK and select the same folders that they are supposedly addressing. Checking and unchecking did not work for me – guess it’s just buggy…
     
    Ali_V_Quest and ManeyMan like this.
  12. garrido86

    garrido86

    Joined:
    Dec 17, 2013
    Posts:
    233
    I can also verify the solution, although it is important that when unchecking, you have to close the preference window and then open it again and tick the checkbox again - then it will work.
     
    sachinbirajdar likes this.
  13. silvergat

    silvergat

    Joined:
    Jun 11, 2020
    Posts:
    22
    It happened to me to
     
  14. silvergat

    silvergat

    Joined:
    Jun 11, 2020
    Posts:
    22
    Still didn’t work for me
     
    Opeth001 likes this.
  15. dalavid88

    dalavid88

    Joined:
    Oct 30, 2020
    Posts:
    1
    Worked like a charm...Though it worked after i did it for both jdk and android sdk....
     
    iHammadArshad likes this.
  16. Tensor_Games

    Tensor_Games

    Joined:
    Dec 16, 2020
    Posts:
    1
    Unity 2020.2.0f1
    Still experiencing that issue.

    Checking-unchecking / defining JAVA_HOME manually in the environment variables and other "mumbo-jumbo"-like solutions from the unity team don't work for me.

    Whem will that be fixed?
     
    Last edited: Dec 22, 2020
    innerspaceat likes this.
  17. akti86

    akti86

    Joined:
    Oct 2, 2016
    Posts:
    1
    how ? I cant uncheck Jdk chekbox to remove
     
  18. chrisasimako53

    chrisasimako53

    Joined:
    Feb 23, 2020
    Posts:
    1
    check /uncheck worked like a charm
     
  19. resistancereborn

    resistancereborn

    Joined:
    Dec 16, 2020
    Posts:
    1
    check /uncheck worked at 2019.4.16f
     
  20. fatheadx

    fatheadx

    Joined:
    Mar 2, 2016
    Posts:
    10
    When is unity planning to fix this issue?
     
  21. ferranases

    ferranases

    Joined:
    Feb 27, 2017
    Posts:
    11
    Last edited: Mar 20, 2021
    SB347, jaym45785 and deptroimotngay like this.
  22. wisarut

    wisarut

    Joined:
    Mar 27, 2013
    Posts:
    3
    For those who have still have this problem (even toggle the button). It look like you need to press run button or submit and restore your project with unity collab or do something until android resolver dialog box popup then you click ok it doesn't matter if the result is failed now you can build your apk
     
  23. DeathApocalypse

    DeathApocalypse

    Joined:
    Sep 29, 2016
    Posts:
    10
    LOL. worked for me as well. simply unchecked and checked the JDK in preferences.
     
  24. huynhhongan

    huynhhongan

    Joined:
    Nov 15, 2016
    Posts:
    1
    Many thanks. It works for me
     
  25. ickydime

    ickydime

    Joined:
    Nov 20, 2012
    Posts:
    110
    Had this happen in 2020.1.17f1 The strange thing was I had 2 projects open. Both android. One built perfectly and the other gave this error. Settings were the same as far as I could tell.

    The uncheck/check solution only worked after I closed the preferences window and re-opening between toggles.
     
    xLeo and leobilck like this.
  26. xLeo

    xLeo

    Joined:
    Sep 21, 2010
    Posts:
    194
    The same thing happened for me. I'm on Unity 2020.3.11f1
     
  27. aman86

    aman86

    Joined:
    Feb 4, 2021
    Posts:
    1
    did you find any solution
     
  28. Chopium

    Chopium

    Joined:
    Jun 15, 2015
    Posts:
    19
    upload_2021-7-12_10-32-21.png
    In 2020.3 I fixed by hard coding the correct paths. The resolver was stuck looking for the version of unity the project was originally created in (2018), even though the editor window showed the correct paths. Seems like an engine bug, but these custom fields are a good workaround.
     
  29. donovand4

    donovand4

    Joined:
    May 8, 2013
    Posts:
    9
    Unity Seriously! This needs to be fixed. I tried manually defining the paths, deselect close and reselect the paths. Still nothing. It was working yesterday and today it stops with this error. The engine is inconsistent! Unity needs to get an android build process that actually works first time. My project is now on hold because the build process keeps changing every day.

    SOLUTION: I had to update from 2020.3.14f1 to 2020.3.15f2 to fix the problem!
     
    Last edited: Aug 2, 2021
  30. dsavickij

    dsavickij

    Joined:
    May 17, 2019
    Posts:
    12
    This issue is acttually comes from 2018 start at least, full unity reinstall doesn't help, i'm having "fun" with this error for couple of years, some how unity doesn't seem to track it's own installation changes and screws setting on each version change, you have to either keep some "working" unity version permanetly on your machine (once that version of JDK works) or have fun with each unity version update, since, with deletion of old version of JDK, paths screw up in Unity and "have fun".

    Thank you Unity...
     
  31. aeldron

    aeldron

    Joined:
    Feb 12, 2013
    Posts:
    32
    Rebooting after setting JAVA_HOME and the path seems to have done the trick for me.
     
  32. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    For those who still have the problem even after toggling the JDK checkbox in Unity, do the following
    1. Download JDK 8 from here.
    2. Install it
    3. Try running now and it should work!

    Thanks,
    VB Team
     
    aeldron likes this.
  33. chitrang313

    chitrang313

    Joined:
    Feb 5, 2018
    Posts:
    3
    set this path(Image Attached) into your environment variable if you are using windows PC.
     

    Attached Files:

  34. Arslanmirza313

    Arslanmirza313

    Joined:
    Oct 12, 2020
    Posts:
    3
    Please check and uncheck JDK in prefrences and if still didnt resolve then please restart your system and then you resolve this issue.
     
  35. Rhoekin

    Rhoekin

    Joined:
    Oct 2, 2017
    Posts:
    2
    While the uncheck-check method works, a permanent solution is to clean install unity hub + editor and all the project files (importing from your source control is the best option).
    This was the method that solved the problem permanently for me, it probably has to do with unity caching enviroment variables (?).
    The error that i was getting about JAVA_HOME was pointing to a path that didnt exist in my systems enviroment variables..
     
  36. sachinbirajdar

    sachinbirajdar

    Joined:
    Feb 23, 2017
    Posts:
    11
    This is problem is still there with Unity 2020.3.2 version with similar solution.
     
  37. Funjam245

    Funjam245

    Joined:
    Dec 2, 2016
    Posts:
    1
    Same issue here on 2021.3.3f1 - unChecking/Checking not working
     
  38. aeldron

    aeldron

    Joined:
    Feb 12, 2013
    Posts:
    32
    If closing/unclosing is really not working for you, after closing and reopening Unity, rebooting your computer, etc, you can try installing Java 8 as @Voxel-Busters is suggesting.

    As a last resort, you might want to try a clean install of the editor. Close any other versions of Unity you might have running, just for good measure, then uninstall and reinstall the editor version causing problems making sure you tick all the Android module boxes.

    upload_2022-5-25_9-8-40.png
     

    Attached Files:

  39. xd-unitydeveloper12

    xd-unitydeveloper12

    Joined:
    May 23, 2022
    Posts:
    8
    Work for me
     
  40. zespin2000

    zespin2000

    Joined:
    Feb 10, 2016
    Posts:
    3
    in my case, the following slightly modified process as mentioned above only works
    1. Uncheck JDK box and leave blank
    2. Attempt a Build ( which will fail of course)
    3. Recheck the JDK box and then Build
     
  41. yahyabozkurt44rara

    yahyabozkurt44rara

    Joined:
    Dec 20, 2021
    Posts:
    1
    29.07.2022 still same problem valid above solutions working
     

    Attached Files:

    • 2.png
      2.png
      File size:
      61.8 KB
      Views:
      211
    • 3.png
      3.png
      File size:
      236.7 KB
      Views:
      205
  42. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    This work-around works for me as well, however, it has to be done every time I open up Unity Editor.

    Are Unity working on a PROPER fix for this @Aurimas-Cernius ?
     
  43. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,902
    There's a blind fix for this issue available:
    * 2020.3 - incoming
    * 2021.3 - available in 2021.3.7f1
    * 2022.2 - available in 2022.2.0a18
     
  44. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    Thank you! Looking very much forward to it.
     
  45. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Ah! Finally!
    Thanks for fixing and sharing!
     
  46. nmnkra

    nmnkra

    Joined:
    Jul 25, 2018
    Posts:
    1
    Hello,
    Previously, deselecting and re-selecting worked for me as well, but later it stopped working. I was about to go crazy. Later I saw your method and tried it. I deselected and got build. The error did not go away in the build, then I tried to make a choice again and froce resolve, this time it was force resolve without any problem. Thanks a lot, good work :)
     
  47. sengunSipahi

    sengunSipahi

    Joined:
    Oct 10, 2020
    Posts:
    1
    i got the same error in 2021.3.8f1 version and this solution works, but how is it still an issue after 9 years
     
  48. pagan_poetry

    pagan_poetry

    Joined:
    Feb 15, 2017
    Posts:
    107
    Unity 2021.3.6f1 still has this issue and simple checking\uncheking worked for me:D
     
  49. tachyon-particle

    tachyon-particle

    Joined:
    Jan 5, 2016
    Posts:
    79
    Unity 2022.2.20

    To get it to fully work, I had to do the following in the exact order:

    1. Assets > External Dependency Manager > Android Resolver > Delete Resolved Libraries
    2. Assets > External Dependency Manager > Android Resolver > Restore Defaults
    3. Uncheck / Check the JDK as suggested earlier
    4. Assets > External Dependency Manager > Android Resolver > Force Resolve
     
  50. unity_17412D978020B89D2E5E

    unity_17412D978020B89D2E5E

    Joined:
    Oct 21, 2022
    Posts:
    3

    worked for me too thanks a lot