Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA_HOME Variable Issues

Tags:

java

java-home

I've seen the numerous other posts on here regarding JAVA_HOME variables and I have tried them all.

When I try and execute any gradle related tasks from the terminal I receive the following error:

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_191

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

If I run WHERE java I get C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe and c:\jdk\bin\java.exe, which leads me to believe there's an issue somewhere with this.

I added C:\Program Files\Java\jdk1.8.0_191 to my path and added JAVA_HOME as a system variable pointing at C:\Program Files\Java\jdk1.8.0_191. What am I missing? I have been banging my head against this for a while now; any help would be greatly appreciated.

EDIT: I have confirmed that C:\Program Files\Java\jdk1.8.0_191 does in fact exist and the contents are

  • bin
  • include
  • jre
  • lib
  • man
  • COPYRIGHT
  • javafx-src.zip
  • LICENSE
  • README
  • release
  • src.zip
  • THIRDPARTYLICENSEREADME
  • THIRDPARTYLICENSEREADME-JAVAFX
like image 843
StormsEdge Avatar asked Feb 04 '20 20:02

StormsEdge


3 Answers

Change your path variable to include %JAVA_HOME%\bin

Remove quote from your JAVA_HOME, it should just be C:\Program Files\Java\jdk1.8.0_191

like image 160
rhowell Avatar answered Sep 22 '22 14:09

rhowell


If you check your PATH variable you will probably find that this directory "C:\Program Files (x86)\Common Files\Oracle\Java\javapath" appears before your JAVA_HOME directory.

Try changing the order, for example:

Instead of:

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%JAVA_HOME%\bin

Make it like this:

%JAVA_HOME%\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath
like image 42
Lionel Cichero Avatar answered Sep 21 '22 14:09

Lionel Cichero


On linux you would do:

export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/jre"
not
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java"

like image 20
Elmasry Avatar answered Sep 22 '22 14:09

Elmasry