Flutter Error : JAVA_HOME is set to an invalid directory: c:\Users\dharm\AppData\Roaming\Code\User\globalStorage\pleiades.java-extension-pack-jdk\17

Error

flutter doctor –android-licenses jab hum ye command chala rahe hai to ERROR: JAVA_HOME is set to an invalid directory: c:\Users\dharm\AppData\Roaming\Code\User\globalStorage\pleiades.java-extension-pack-jdk\17 Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

This error is given by setting the JAVA_HOME environment variable. The JAVA_HOME variable stores the path to the Java installation directory in your system. Flutter requires the Java Development Kit (JDK) for Android development.

You have given here that the directory path is invalid:

c:\Users\dharm\AppData\Roaming\Code\User\globalStorage\pleiades.java-extension-pack-jdk\17

Solution

To fix this error, you need to set the path to the correct Java installation directory. Follow the steps given below:

  1. First, find the path to the correct Java JDK installation directory. This can usually be something like C:\Program Files\Java\jdk1.x.x_x or C:\Program Files\Android\Android Studio\jre. If your Java JDK path is different, note that.
  2. To set the JAVA_HOME environment variable for Windows, follow these steps:
  • Open Computer Properties (by pressing the Windows key + Pause/Break key)
  • Click on “Advanced system settings” in the left sidebar.
  • Click the “Environment Variables” button on the “Advanced” tab.
  • Click the “New” button in the System Variables section.
  • variable name: JAVA_HOME
  • Variable Value: Path to the Java JDK installation directory (eg, C:\Program Files\Java\jdk1.x.x_x)
  • After saving, restart the terminal or command prompt and run the flutter doctor –android-license command. Now this command should run correctly.

This way, you should not encounter any errors accepting Flutter Android licenses after setting the java_home environment variable.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x