简体   繁体   中英

JAVA_HOME is set to an invalid directory:

I have set JAVA_HOME in my system C:\Program Files\Java\jdk1.8.0_ 131\bin; and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried all the ways, but not able to resolve this issue:

ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_ 131\bin;

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

You should set it with C:\Program Files\Java\jdk1.8.0_12 .

\bin is not required.

JAVA_HOME should point to the home jdk directory, and not to jdk/bin directory.

You need to set the JAVA_HOME like this:

JAVA_HOME="C:\Program Files\Java\jdk1.8.0_131"

Remove the \bin , and also remove the ; at the end. After restart the cmd and run.

Try the following:

  • Remove \bin from JAVA_HOME path.
  • Open new command line window.
  • Run your command as an administrator.

On Window 10, the problem was with the semicolon ; .

Go to edit the system environment variables and delete the semicolon at the end of JAVA_HOME value C:\Program Files\Java\jdk1.8.0_144

In other words, convert this C:\Program Files\Java\jdk1.8.0_12; to C:\Program Files\Java\jdk1.8.0_12

You might have to delete your entry in the Windows Dialog and create a new one. If you ever had multiple entries and get the bigger Form view , Windows automatically inserts a ; at the end of each entry, even if you only have one entry left.

JAVA_HOME should be C:\Program Files\Java\jdk1.8.0_172 don't include semi-colon(;) or bin in path. Any jdk version above 7 will work. Also, you need to re-start the cmd

On linux and mac :

  1. To find the path java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
  2. result eg java.home = /usr/lib/jvm/java-11-openjdk-amd64
  3. copy: /usr/lib/jvm/java-11-openjdk-amd64
  4. Add line in your config bash file (eg ~/.zshrc ): export JAVA_HOME=<resultFirstStep>

set JAVA_HOME as C:\Program Files\Java\jdk1.8.0_172

do not use semicolon ";" with above JAVA_HOME value

To verify that it is correctly set, Go to command prompt check for C:.......> sdkmanager --list

a complete list will appear that will let you now that it is successfully saved.

else it will show error that JAVA_HOME path is not correctly set.

设置 JAVA_HOME 变量后,以管理员身份运行 android studio

First try removing the '\bin' from the path and set the home directory JAVA_HOME as below: JAVA_HOME : C:\Program Files\Java\jdk1.8.0_131

Second Update System PATH:

  1. In “Environment Variables” window under “System variables” select Path
  2. Click on “Edit…”
  3. In “Edit environment variable” window click “New”
  4. Type in %JAVA_HOME%\bin

Third restart your docker.

Refer to the link for setting the java path in windows.

Please remove /bin and even semi colon ; from JAVA_HOME to resolve.

You need to set with only C:\Program Files\Java\jdk1.8.0_12.

And check with using new cmd. It will be updated

I found this while googling the issue with android licences when installing Flutter.

For Linux , update Your ~/.bashrc (or other shell config) file by adding this line at the end:

JAVA_HOME=/usr/local/android-studio/jre

Note: I installed Android studio by following the official installation guide for Linux (link) .

For Windows , use the android studio's path to the jre directory and update the environment variable with the right value.

Then, run flutter doctor --android-licenses and press y to review the licences which are not accepted. Press y for each of the licences. It will ask Accept? (y/N): Accept? (y/N): at the end of the license file. After You accept all unaccepted licences, You should see:

All SDK package licenses accepted

i think you need to remove the ';' from the end of the java path.

Check for duplicate entries of JAVA_HOME in system variables.

In my case none of the above answers worked but I had two entries for JAVA_HOME and removing one worked.

I have set JAVA_HOME in my system C:\\Program Files\\Java\\jdk1.8.0_ 131\\bin; and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried all the ways, but not able to resolve this issue:

ERROR: JAVA_HOME is set to an invalid directory: C:\\Program Files\\Java\\jdk1.8.0_ 131\\bin;

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

I have set JAVA_HOME in my system C:\\Program Files\\Java\\jdk1.8.0_ 131\\bin; and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried all the ways, but not able to resolve this issue:

ERROR: JAVA_HOME is set to an invalid directory: C:\\Program Files\\Java\\jdk1.8.0_ 131\\bin;

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

I was using jenv

In my case, I was using jenv but did not set the java version, so the path that jenv was pointing actually a Java installation.

When I ran echo $JAVA_HOME , it showed /Users/username/.jenv/versions/system , and there was no such file or directory.

Set a version of java

I just had to do jenv global 15 or jenv local 15 , to specify what version I wanted to actually use, and JAVA_HOME changed when I re-ran echo $JAVA_HOME .

While copying the JDK PATH, exclude \bin folder in it.

eg

C:\Program Files\Java\jdk-15.0.2

your path should look like blow, you just need to edit it and remove \bin folder

C:\Program Files\Java\jdk-15.0.2\bin

Change JAVA_HOME in Environment variable to this

C:\Program Files\Android\Android Studio\jbr

and since Electric Eel use jbr copy jbr file and replace it into jre then restart ur pc. It worked for me after days of tedious try and error days

我在项目的 vs 代码中设置了这样的设置。它为我工作

JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_321.jdk/Contents/Home"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM