Error java home is set to an invalid directory

I have set JAVA_HOME in my system C:Program FilesJavajdk1.8.0_ 131bin; and I am trying to run cordova command( cordova build ) on command prompt, but I'm getting the error bellow. I have tried ...

I have set JAVA_HOME in my system C:Program FilesJavajdk1.8.0_
131bin;
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
FilesJavajdk1.8.0_ 131bin;

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

Samvel Aleqsanyan's user avatar

asked Jul 19, 2017 at 6:41

Nagarajan M's user avatar

13

You should set it with C:Program FilesJavajdk1.8.0_12.

bin is not required.

halfer's user avatar

halfer

19.7k17 gold badges95 silver badges183 bronze badges

answered Jul 19, 2017 at 6:43

Sagar Gangwal's user avatar

Sagar GangwalSagar Gangwal

7,2893 gold badges22 silver badges37 bronze badges

2

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 FilesJavajdk1.8.0_131"

Samvel Aleqsanyan's user avatar

answered Jul 19, 2017 at 6:46

Kiran Choudhary's user avatar

1

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

Samvel Aleqsanyan's user avatar

answered Oct 1, 2017 at 12:53

Akshay's user avatar

AkshayAkshay

99711 silver badges21 bronze badges

3

Try the following:

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

Samvel Aleqsanyan's user avatar

answered Mar 31, 2018 at 22:06

Abdulrahman Hashem's user avatar

1

On linux and mac:

  1. To find the path java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
  2. result e.g. 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 (e.g.~/.zshrc): export JAVA_HOME=<resultFirstStep>

answered Jul 21, 2021 at 14:23

LuanLuanLuan's user avatar

1

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 FilesJavajdk1.8.0_144

In other words, convert this C:Program FilesJavajdk1.8.0_12; to C:Program FilesJavajdk1.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.

Jan K.'s user avatar

answered Jun 7, 2018 at 11:38

Mehrdad Salimi's user avatar

Mehrdad SalimiMehrdad Salimi

1,3384 gold badges16 silver badges31 bronze badges

0

JAVA_HOME should be C:Program FilesJavajdk1.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

answered Jul 30, 2018 at 11:07

Pawan Maheshwari's user avatar

Pawan MaheshwariPawan Maheshwari

14.9k1 gold badge47 silver badges50 bronze badges

0

set JAVA_HOME as C:Program FilesJavajdk1.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.

answered Jul 10, 2018 at 6:59

Shailja Pandey's user avatar

0

First try removing the ‘bin’ from the path and set the home directory JAVA_HOME as below:
JAVA_HOME : C:Program FilesJavajdk1.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.

answered Sep 2, 2020 at 8:22

Subrata Sarkar's user avatar

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

answered Sep 30, 2020 at 11:18

Shashank G's user avatar

Shashank GShashank G

8741 gold badge15 silver badges25 bronze badges

After setting the JAVA_HOME variable, run android studio as administrator

answered Apr 30, 2019 at 1:21

Raafat Alhmidi's user avatar

You need to set with only C:Program FilesJavajdk1.8.0_12.

And check with using new cmd. It will be updated

answered Jun 17, 2019 at 7:18

Mak's user avatar

MakMak

1,0687 silver badges19 bronze badges

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): at the end of the license file.
After You accept all unaccepted licences, You should see:

All SDK package licenses accepted

answered Sep 29, 2020 at 16:06

Aleksandar's user avatar

AleksandarAleksandar

3,1481 gold badge36 silver badges42 bronze badges

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

e.g.

C:Program FilesJavajdk-15.0.2

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

C:Program FilesJavajdk-15.0.2bin

answered Jun 25, 2022 at 19:16

Rahat Shah's user avatar

Change JAVA_HOME in Environment variable
to this

C:Program FilesAndroidAndroid Studiojbr

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

answered Jan 16 at 16:55

Suretion's user avatar

SuretionSuretion

631 gold badge1 silver badge11 bronze badges

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

answered Oct 1, 2018 at 8:10

Mostafa Yehya's user avatar

1

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.

answered Jun 1, 2021 at 6:54

Shivam Mishra's user avatar

1

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.

answered Jun 25, 2021 at 16:22

Ben Butterworth's user avatar

Ben ButterworthBen Butterworth

18.2k7 gold badges93 silver badges142 bronze badges

i have set like this in vs code for project.its working for me

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

answered Mar 6, 2022 at 21:11

sweetnandha cse's user avatar

How to fix JAVA_HOME errors

There’s nothing worse than installing your favorite Java-based application — such as Minecraft, Maven, Jenkins or Apache Pig — only to run into a JAVA_HOME is set to an invalid directory or a JAVA_HOME is not defined correctly error as soon as you boot up the program.

Well, there’s no need to fret. Here’s how to fix the most common JAVA_HOME errors.

How to fix JAVA_HOME not found errors

It’s worth noting that there aren’t standardized JAVA_HOME error messages that people will encounter. There are many different ways that a given JAVA_HOME error might be logged.

For example, one of the most common JAVA_HOME configuration problems arises from the fact that the environment variable has never actually been set up. Such a scenario tends to trigger the following error messages:

  • Error: JAVA_HOME not found in your environment
  • Error: JAVA_HOME not set
  • Error: JAVA_HOME is not set currently
  • Error: JAVA_HOME is not set
  • Error: Java installation exists but JAVA_HOME has not been set
  • Error: JAVA_HOME cannot be determined from the registry

How do you fix the JAVA_HOME not found problem?

Well, you fix this by in the Windows environment variable editor where you can actually add a new system variable. If you know your way around the Windows operating system, you should be able to add the JAVA_HOME environment variable to your configuration and have it point to the installation root of your JDK within minutes. The Windows 10 setting looks like this:

JAVA_HOME not found

Fix JAVA_HOME not found errors

As mentioned above, the JAVA_HOME variable must point to the installation root of a JDK, which means a JDK must actually be installed. If one isn’t, then you better hop to it and get that done.

The JAVA_HOME is set to an invalid directory fix

The next most common JAVA_HOME error message is JAVA_HOME is set to an invalid directory. The error message is delightfully helpful, because it tells you in no uncertain terms the environment variable does in fact exist. And, it also tells you it’s not pointing to the right place, which is helpful as well. All you need to do to fix this error is edit the JAVA_HOME variable and point it to the correct directory.

The JAVA_HOME environment variable must point to the root of the installation folder of a JDK. It cannot point to a sub-directory of the JDK, and it cannot point to a parent directory that contains the JDK. It must point directly at the JDK installation directory itself. If you encounter the JAVA_HOME invalid directory error, make sure the name of the installation folder and the value of the variable match.

An easy way to see the actual value associated with the JAVA_HOME variable is to simply echo its value on the command line. In Windows, write:

>/echo %JAVA_HOME%
C:/_JDK13.0

On an Ubuntu, Mac or Linux machine, the command uses a dollar sign instead of percentages:

:-$ echo $JAVA_HOME
/usr/lib/jvm/java-13-oracle

Find JAVA_HOME Ubuntu

How to find JAVA_HOME in Mac or Ubuntu Linux computers.

Steer clear of the JDK bin directory

One very common developer mistake that leads to the JAVA_HOME is set to an invalid directory error is pointing JAVA_HOME to the bin sub-directory of the JDK installation. That’s the directory you use to configure the Windows PATH, but it is wrong, wrong, wrong when you set JAVA_HOME. If you point JAVA_HOME at the bin directory, you’ll need to fix that.

This misconfiguration also manifests itself with the following error messages:

  • JAVA_HOME is set to an invalid directory
  • Java installation exists but JAVA_HOME has been set incorrectly
  • JAVA_HOME is not defined correctly
  • JAVA_HOME does not point to the JDK

Other things that might trigger this error include spelling mistakes or case sensitivity errors. If the JAVA_HOME variable is set as java_home, JAVAHOME or Java_Home, a Unix, Linux or Ubuntu script will have a hard time finding it. The same thing goes for the value attached to the JAVA_HOME variable.

The JAVA_HOME does not point to the JDK error

One of the most frustrating JAVA_HOME errors is JAVA_HOME does not point to the JDK.

Here’s a little bit of background on this one.

When you download a JDK distribution, some vendors include a Java Runtime Environment (JRE) as well. And when the JAVA_HOME environment variable gets set, some people point it at the JRE installation folder and not the JDK installation folder. When this happens, we see errors such as:

  • JAVA_HOME does not point to a JDK
  • JAVA_HOME points to a JRE not a JDK
  • JAVA_HOME must point to a JDK not a JRE
  • JAVA_HOME points to a JRE

To fix this issue,  see if you have both a JRE and JDK installed locally. If you do, ensure that the JAVA_HOME variable is not pointing at the JRE.

JAVA_HOME and PATH confusion

After you’ve downloaded and installed the JDK, sometimes another problem can plague developers. If you already have programs that installed their own version of the JDK, those programs could have added a reference to that specific JDK in the Linux or Windows PATH setting. Some programs will run Java using the program’s availability through the PATH first, and JAVA_HOME second. If another program has installed a JRE and put that JRE’s bin directory on the PATH, your JAVA_HOME efforts may all be for naught.

However, you can address this issue. First, check the Ubuntu or Windows PATH variable and look to see if any other JRE or JDK directory has been added to it. You might be surprised to find out that IBM or Oracle has at some prior time performed an install without your knowledge. If that’s the case, remove the reference to it from the PATH, add your own JDK’s bin directory in there, and restart any open command windows. Hopefully that will solve the issue.

Of course, there is never any end to the configurations or settings that can trigger JAVA_HOME errors. If you’ve found any creative solutions not mentioned here, please add your expert insights to the comments.

Hello fellow Ubuntu users,

I am trying to learn how to write modifications to Minecraft. In order to follow the tutorial I am using, I need to run a «gradlew». The command is as follows

./gradlew setupDecompWorkspace eclipse

This yields the following

ERROR: JAVA_HOME is set to an invalid directory: /usr/local/java/jdk1.8.0_20

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

Obviously I don’t know what to do or even what this means. Any help is much appreciated.

asked Nov 27, 2014 at 20:05

Joseph_carp's user avatar

1

Before running the command try entering:

export JAVA_HOME="path_to_java_home"

Where path_to_java_home is the folder where your bin/java is.

If java is properly installed you can find it’s location, by using the command:

readlink -f $(which java)

Don’t forget to remove bin/java from the end of the path while putting it into JAVA_HOME

answered Nov 27, 2014 at 20:25

Andrew Onischuk's user avatar

Andrew OnischukAndrew Onischuk

5601 gold badge6 silver badges6 bronze badges

7

To make it automatic on Linux/Ubuntu, add these lines at the end of your .bashrc:

JAVA_HOME=$(dirname $( readlink -f $(which java) ))
JAVA_HOME=$(realpath "$JAVA_HOME"/../)
export JAVA_HOME

This gets java executable, then climbs up a directory level

To designate the default java version/executable on Debian/Ubuntu, run this once:

sudo update-alternatives --config java

This builds up on previous answer by Andrew Onischuk (thanks!)

answered Dec 7, 2016 at 20:05

Tudor Ilisoi's user avatar

0

Get your Java path using the command

whereis java

The following is a possible output depending on your default Java version

java: /usr/bin/java /usr/share/java /usr/lib/jvm/jdk1.8.0_241/jre/bin/java

Maven need to pick the Java location (home) so you can export the Java path using the following command

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_241/jre

This will allow Maven to pick the java version and location in the /etc/environment file

Optionally you can add this in the /etc/environment manually using the following command

sudo nano /etc/environment

and edit the JAVA_HOME=/usr/lib/jvm/jdk1.8.0_241/jre/

answered Mar 11, 2020 at 8:01

Jose Mhlanga's user avatar

Try to edit /usr/bin/gradle

Comment the line «export JAVA_HOME=/usr/lib/jvm/default-java» with a #

this: #export JAVA_HOME=/usr/lib/jvm/default-java

answered Apr 15, 2018 at 20:49

starwatcher's user avatar

1

Run with sudo

sudo ./gradlew setupDecompWorkspace eclipse

You are not a sudo doer for running this command

So Add sudo to it.

answered Aug 21, 2020 at 13:08

Mayank Goyal's user avatar

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to run my cordova command But I am facing following error ERROR: JAVA_HOME is set to an invalid directory in Java. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

Contents

  1. How This Error Occurs ?
  2. How To Solve ERROR: JAVA_HOME is set to an invalid directory Error ?
  3. Solution 1: set the JAVA_HOME like this
  4. Solution 2: Remove the bin
  5. Summary

How This Error Occurs ?

I am trying to run my cordova command But I am facing following error.

ERROR: JAVA_HOME is set to an invalid directory: C:Program FilesJavajdk1.8.0_ 131bin;

  1. How To Solve ERROR: JAVA_HOME is set to an invalid directory Error ?

    To Solve ERROR: JAVA_HOME is set to an invalid directory Error Error Is saying that There is just no need to add bin into PATH variable. You need to set the JAVA_HOME like this. JAVA_HOME=”C:Program FilesJavajdk1.8.0_131″ Just set JAVA_HOME like this and your error will be solved.

  2. ERROR: JAVA_HOME is set to an invalid directory

    To Solve ERROR: JAVA_HOME is set to an invalid directory Error Error Is saying that There is just no need to add bin into PATH variable. You need to set the JAVA_HOME like this. JAVA_HOME=”C:Program FilesJavajdk1.8.0_131″ Just set JAVA_HOME like this and your error will be solved.

Solution 1: set the JAVA_HOME like this

Error Is saying that There is just no need to add bin into PATH variable. You need to set the JAVA_HOME like this.

JAVA_HOME="C:Program FilesJavajdk1.8.0_131"

Just set JAVA_HOME like this and your error will be solved.

Solution 2: Remove the bin

  1. Remove the bin from PATH variable.
  2. also remove the ; at the end
  3. After restart the cmd and run again.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

  • Class has been compiled by a more recent version of the Java Environment

Содержание

  1. Fix JAVA_HOME errors | Invalid directory | Not set or defined | Points to JRE
  2. ERROR: JAVA_HOME is set to an invalid directory #13154
  3. Comments
  4. Footer

Fix JAVA_HOME errors | Invalid directory | Not set or defined | Points to JRE

Community driven content discussing all aspects of software development from DevOps to design patterns.

  • JAVA_HOME – TheServerSide.com
  • How to set JAVA_HOME in Windows and echo the result – TheServerSide.com
  • How do I install Java on Ubuntu? – TheServerSide.com

There’s nothing worse than installing your favorite Java-based application — such as Minecraft, Maven, Jenkins or Apache Pig — only to run into a JAVA_HOME is set to an invalid directory or a JAVA_HOME is not defined correctly error as soon as you boot up the program.

Well, there’s no need to fret. Here’s how to fix the most common JAVA_HOME errors.

How to fix JAVA_HOME not found errors

It’s worth noting that there aren’t standardized JAVA_HOME error messages that people will encounter. There are many different ways that a given JAVA_HOME error might be logged.

For example, one of the most common JAVA_HOME configuration problems arises from the fact that the environment variable has never actually been set up. Such a scenario tends to trigger the following error messages:

  • Error: JAVA_HOME not found in your environment
  • Error: JAVA_HOME not set
  • Error: JAVA_HOME is not set currently
  • Error: JAVA_HOME is not set
  • Error: Java installation exists but JAVA_HOME has not been set
  • Error: JAVA_HOME cannot be determined from the registry

How do you fix the JAVA_HOME not found problem?

Well, you fix this by in the Windows environment variable editor where you can actually add a new system variable. If you know your way around the Windows operating system, you should be able to add the JAVA_HOME environment variable to your configuration and have it point to the installation root of your JDK within minutes. The Windows 10 setting looks like this:

Fix JAVA_HOME not found errors

As mentioned above, the JAVA_HOME variable must point to the installation root of a JDK, which means a JDK must actually be installed. If one isn’t, then you better hop to it and get that done.

The JAVA_HOME is set to an invalid directory fix

The next most common JAVA_HOME error message is JAVA_HOME is set to an invalid directory. The error message is delightfully helpful, because it tells you in no uncertain terms the environment variable does in fact exist. And, it also tells you it’s not pointing to the right place, which is helpful as well. All you need to do to fix this error is edit the JAVA_HOME variable and point it to the correct directory.

The JAVA_HOME environment variable must point to the root of the installation folder of a JDK. It cannot point to a sub-directory of the JDK, and it cannot point to a parent directory that contains the JDK. It must point directly at the JDK installation directory itself. If you encounter the JAVA_HOME invalid directory error, make sure the name of the installation folder and the value of the variable match.

An easy way to see the actual value associated with the JAVA_HOME variable is to simply echo its value on the command line. In Windows, write:

On an Ubuntu, Mac or Linux machine, the command uses a dollar sign instead of percentages:

How to find JAVA_HOME in Mac or Ubuntu Linux computers.

Steer clear of the JDK bin directory

One very common developer mistake that leads to the JAVA_HOME is set to an invalid directory error is pointing JAVA_HOME to the bin sub-directory of the JDK installation. That’s the directory you use to configure the Windows PATH, but it is wrong, wrong, wrong when you set JAVA_HOME. If you point JAVA_HOME at the bin directory, you’ll need to fix that.

This misconfiguration also manifests itself with the following error messages:

  • JAVA_HOME is set to an invalid directory
  • Java installation exists but JAVA_HOME has been set incorrectly
  • JAVA_HOME is not defined correctly
  • JAVA_HOME does not point to the JDK

Other things that might trigger this error include spelling mistakes or case sensitivity errors. If the JAVA_HOME variable is set as java_home, JAVAHOME or Java_Home, a Unix, Linux or Ubuntu script will have a hard time finding it. The same thing goes for the value attached to the JAVA_HOME variable.

The JAVA_HOME does not point to the JDK error

One of the most frustrating JAVA_HOME errors is JAVA_HOME does not point to the JDK.

Here’s a little bit of background on this one.

When you download a JDK distribution, some vendors include a Java Runtime Environment (JRE) as well. And when the JAVA_HOME environment variable gets set, some people point it at the JRE installation folder and not the JDK installation folder. When this happens, we see errors such as:

  • JAVA_HOME does not point to a JDK
  • JAVA_HOME points to a JRE not a JDK
  • JAVA_HOME must point to a JDK not a JRE
  • JAVA_HOME points to a JRE

To fix this issue, see if you have both a JRE and JDK installed locally. If you do, ensure that the JAVA_HOME variable is not pointing at the JRE.

JAVA_HOME and PATH confusion

After you’ve downloaded and installed the JDK, sometimes another problem can plague developers. If you already have programs that installed their own version of the JDK, those programs could have added a reference to that specific JDK in the Linux or Windows PATH setting. Some programs will run Java using the program’s availability through the PATH first, and JAVA_HOME second. If another program has installed a JRE and put that JRE’s bin directory on the PATH, your JAVA_HOME efforts may all be for naught.

However, you can address this issue. First, check the Ubuntu or Windows PATH variable and look to see if any other JRE or JDK directory has been added to it. You might be surprised to find out that IBM or Oracle has at some prior time performed an install without your knowledge. If that’s the case, remove the reference to it from the PATH, add your own JDK’s bin directory in there, and restart any open command windows. Hopefully that will solve the issue.

Of course, there is never any end to the configurations or settings that can trigger JAVA_HOME errors. If you’ve found any creative solutions not mentioned here, please add your expert insights to the comments.

Enterprises increasingly rely on APIs to interact with customers and partners. It all starts with knowing which type of API is .

Although modern software systems can be inordinately complex, architects can still use simple napkin math to glean quick .

To establish the right development team size, managers must look at each member’s responsibilities and communication paths, as .

GitHub Actions required workflows and configuration variables can reduce duplicate configuration code and shore up policy .

Learn how low-code concepts and practices code can help enterprise developers be more efficient, create valuable apps more .

The rise of AI-assisted workflows will facilitate software development security amid growing open source vulnerabilities, but .

In 2023, companies expect to increase spending on public cloud applications and infrastructure, and hyperscalers that have .

EC2 instances that are improperly sized drain money and restrict performance demands on workloads. Learn how to right-size EC2 .

To add another level of security, find out how to automatically rotate keys within Azure key vault with step-by-step instructions.

Avast threat researchers detected exploitation of a Windows zero-day flaw in the wild, and organizations are being urged to patch.

Beneath the buzz around tech innovations at CES were discussions about cybersecurity and how to prevent the next generation of .

Enterprise cybersecurity hygiene must be a shared responsibility between employees and employers. Follow these steps to get the .

Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates .

There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service .

AWS users face a choice when deploying Kubernetes: run it themselves on EC2 or let Amazon do the heavy lifting with EKS. See .

Источник

ERROR: JAVA_HOME is set to an invalid directory #13154

JAVA_HOME is set properly but still, I face the issue that JAVA_HOME is setup invalid directory.
This is my PowerShell output:

The text was updated successfully, but these errors were encountered:

Always look at the first error message, not the last. The first is about licenses.
Run flutter doctor for more details.

i changed the JAVA_HOME variable to value C:Program FilesAndroidAndroid Studiojre in Environment Variables and it solve the above mentioned error

i changed the JAVA_HOME variable to value C:Program FilesAndroidAndroid Studiojre in Environment Variables and it solve the above mentioned error

Yeah this worked for me! Thanks

i changed the JAVA_HOME variable to value C:Program FilesAndroidAndroid Studiojre in Environment Variables and it solve the above mentioned error

This worked for me too, thanks!

If You are on Linux, just update Your

/.bashrc (or other shell config) file by adding this line at the end:

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

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): at the end of the license file.
After You accept all unaccepted licences, You should see:

i changed the JAVA_HOME variable to value C:Program FilesAndroidAndroid Studiojre in Environment Variables and it solve the above mentioned error

Yeah this worked for me! Thanks

i changed the JAVA_HOME variable to value C:Program FilesAndroidAndroid Studiojre in Environment Variables and it solve the above mentioned error

thanx! this help me too

My problem was resolved by setting JAVA_HOME variable to C:Program FilesAndroidAndroid Studiojre

In order to overcome the post warning, executed «flutter doctor —android-licenses» and press y for the subsequent cases.

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

© 2023 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Today We are Going To Solve ERROR: JAVA_HOME is set to an invalid directory in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

Contents

  • 1 How to Fix ERROR: JAVA_HOME is set to an invalid directory Error?
    • 1.1 Solution 1 : set it with C:Program FilesJavajdk1.8.0_12
    • 1.2 Solution 2 : Set the JAVA_HOME
    • 1.3 Solution 2 : Remove the bin
  • 2 Conclusion
    • 2.1 Also Read These Solutions
  1. How to Fix ERROR: JAVA_HOME is set to an invalid directory Error?

    To Fix ERROR: JAVA_HOME is set to an invalid directory Error just set it with C:Program FilesJavajdk1.8.0_12. To solve this error just set it with C:Program FilesJavajdk1.8.0_12

  2. ERROR: JAVA_HOME is set to an invalid directory

    To Fix ERROR: JAVA_HOME is set to an invalid directory Error just Set the JAVA_HOME. You have to set the JAVA_HOME just like belowJAVA_HOME="C:Program FilesJavajdk1.8.0_131"

Solution 1 : set it with C:Program FilesJavajdk1.8.0_12

To solve this error just set it with C:Program FilesJavajdk1.8.0_12

Solution 2 : Set the JAVA_HOME

You have to set the JAVA_HOME just like below

JAVA_HOME="C:Program FilesJavajdk1.8.0_131"

Solution 2 : Remove the bin

Remove the bin from your path variable and then remove the ; at the end.

Then restart cmd and run it.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read These Solutions

  • UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block
  • Error: PostCSS plugin tailwindcss requires PostCSS 8
  • ERROR: Could not find tools.jar. Please check that C:Program FilesJavajre1.8.0_151 contains a valid JDK installation
  • java.lang.IllegalArgumentException: Malformed uxxxx encoding
  • Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2

How can we help you today?



Modified on: Mon, 6 Apr, 2020 at 1:35 PM


Description

If you have multiple versions of Java installed on your Windows computer or the variable value does not match the installation path, this error may occur when attempting to run the genrocket command.

Troubleshooting Steps

Complete the steps to resolve: 

  • Check the actual path of Java. The default path should be one the following for most Windows computers (unless a custom install was performed):
    • C:Program Files (x86)Java*Version #*
    • C:Program FilesJava*Version #*
  • Next, in the Environment Variables configuration, view the JAVA_HOME variable value in the System Variables section.
  • Here is an example of an invalid path. The primary path is correct, but contains 2 directories for JRE and JDK. The correct directory needs to be displayed here. If it is a custom install, the entire path might need to be altered.



  • Correct the variable value by clicking Edit and typing or browsing to the appropriate path. 
  • Click OK to save the change and close the System Variables window.
  • Click OK to close the System Properties window.
  • Be certain to exit the command window and open a new instance before trying the genrocket command again.
  • If the JAVA_HOME variable path is correct, the command should run successfully.

Note: This error will also come up when an unsupported version of Java is used. If an unsupported version is being used, you will need to install a correct version and then check the path in this variable again to ensure it is correct.

Note: Additionally, this problem is more likely to occur when using Java Runtime Environment (JRE). Better results are typically received by using a supported version of the Java Development Kit (JDK). See Installation Overview for more information about what versions are supported. 


Did you find it helpful?
Yes

No

Send feedback

Sorry we couldn’t be helpful. Help us improve this article with your feedback.

Related Articles

    Во многих статьях в интернете, документации к инструментам для разработки на Java и в книгах зачастую упоминается JAVA_HOME. Что же такое JAVA_HOME?

    JAVA_HOME это переменная окружения, указывающая на директорию с установленным JDK (Java Development Kit, комплект разработчика Java). JAVA_HOME это соглашение, используемое во многих программах из экосистемы Java.

    Какие программы используют JAVA_HOME

    • Intellij IDEA, Eclipse, NetBeans
    • Apache Maven, Apache Ant, Gradle
    • Apache Tomcat
    • Jenkins

    Некоторые игры, написанные на Java (например, Minecraft), тоже могут требовать установленной переменной JAVA_HOME.

    Ошибки, связанные с JAVA_HOME

    Если переменная окружения JAVA_HOME не определена, некоторые программы могут выдавать следующие ошибки:

    • Переменная среды java_home не определена
    • Cannot determine a valid Java Home
    • JAVA_HOME is set to an invalid directory
    • JAVA_HOME is not defined correctly
    • JAVA_HOME environment variable is not set
    • JAVA_HOME command not found
    • JAVA_HOME not found in your environment
    • JAVA_HOME does not point to the JDK

    При появлении таких ошибок просто установите переменную JAVA_HOME

    Как установить переменную окружения JAVA_HOME в Windows

    Сперва вам нужно установить JDK или JRE.

    • Установите JDK, если вы занимаетесь разработкой программ на Java
    • Установите JRE, если вам нужно только запустить прикладную программу на Java

    После установки JDK либо JRE запишите путь установки, он понадобится.

    Теперь щёлкните правой кнопкой на «Мой компьютер» → «Свойства» → «Дополнительные параметры системы» → «Переменные среды…». В разделе «Системные переменные» нажмите кнопку «Создать…» и укажите следующие данные:

    Имя переменной JAVA_HOME
    Значение переменной Путь к директории JDK / JRE, например:
    C:Javajdk-11.0.6

    Сохраните изменения, кликнув «OK». Теперь выберите в списке переменную окружения Path и нажмите «Изменить…». В конце списка добавьте строчку со значением «%JAVA_HOME%bin«

    Для проверки откройте консоль (Win+R, cmd) и укажите последовательно укажите две команды:

    echo %JAVA_HOME%
    java --version

    Если вы правильно установили JDK/JRE и правильно установили переменные окружения, вы увидите вывод наподобие этого:

    Это будет служить результатом того, что переменная JAVA_HOME установлена правильно и Java работает из командной строки.

    Резюме

    В данной статье мы рассказали вам, что являет собой переменная окружения JAVA_HOME, где она используется и как её корректно указать.

    Понравилась статья? Поделить с друзьями:
  • Error java home environment variable is not set
  • Error java error release version 5 not supported как исправить
  • Error java error release version 5 not supported maven
  • Error java error release version 5 not supported intellij
  • Error java compilation failed internal java compiler error