- 1 year ago
flutter doctor cannot execute AdoptOpenJDK to determine the version
If you encounter an error while running flutter doctor
stating that it cannot execute AdoptOpenJDK to determine the version, you can try the following steps to resolve the issue:
Ensure JDK is Installed: Verify that you have the Java Development Kit (JDK) installed on your system. You can download the latest version of the JDK from the official Oracle website or AdoptOpenJDK website.
Set JAVA_HOME Environment Variable: Set the
JAVA_HOME
environment variable to the installation path of your JDK. Follow these steps:- Open the Environment Variables settings on your system (search for "Environment Variables" in the Start menu).
- Click "Environment Variables" to open the Environment Variables dialog.
- Under "System Variables," click "New" to add a new system variable.
- Enter
JAVA_HOME
as the variable name. - Enter the JDK installation path as the variable value (e.g.,
C:\Program Files\Java\jdk1.8.0_291
). - Click "OK" to save the variable.
Update PATH Variable: Add the JDK's
bin
directory to thePATH
environment variable. Follow these steps:- In the Environment Variables dialog, find the
PATH
variable under "System Variables" and click "Edit." - Append
;%JAVA_HOME%\bin
to the existing variable value. - Click "OK" to save the variable.
- In the Environment Variables dialog, find the
Restart Command Prompt or Terminal: If you had any open command prompt or terminal windows, close and reopen them to ensure they pick up the updated environment variables.
Run
flutter doctor
again: Open a new command prompt or terminal window and runflutter doctor
again to check if the error is resolved. The command should now be able to execute AdoptOpenJDK and determine the version.
By setting the JAVA_HOME
environment variable and updating the PATH
variable to include the JDK's bin
directory, Flutter will be able to locate the JDK and determine its version when running flutter doctor
.