错误:未设置 JAVA_HOME 并且在您的 flutter PATH 中找不到“java"命令.扑腾 [英] ERROR: JAVA_HOME is not set and no 'java' command could be found in your flutter PATH. in flutter

查看:24
本文介绍了错误:未设置 JAVA_HOME 并且在您的 flutter PATH 中找不到“java"命令.扑腾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Android Studio 4.1 并尝试运行现有项目.但它给出了这样的错误:

错误:未设置 JAVA_HOME 并且在您的 PATH 中找不到java"命令.请在您的环境中设置 JAVA_HOME 变量以匹配Java 安装的位置.

解决方案

你必须设置JAVA_HOME环境变量.

在 Windows 上,我解决了以下问题:

  1. 点击环境变量...".

  2. 点击新建".

  3. 填写变量名";带有JAVA_HOME"的字段.

  4. 填写变量值";带有在您的计算机上安装 Java 的路径.(对我来说,它在C:\Program Files\Java\"下)

  5. 点击确定"并关闭所有对话框.

  6. 重新启动您的 IDE/终端.(不要跳过这一步)

I installed Android Studio 4.1 and trying to run existing project. But it gives error like this:

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

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

解决方案

You have to set the JAVA_HOME Environment Variable.

On Windows, I solved the issue as follows:

  1. Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused me an error that required me to downgrade.)

  2. Set the "JAVA_HOME" Environment Variable:

    • Open Windows Search, type in "env", and choose "Edit the system environment variables".

    • Click on "Environment Variables...".

    • Click on "New".

    • Fill in the "variable name" field with "JAVA_HOME".

    • Fill in the "variable value" with the path to where Java is installed on your computer. (for me it was under "C:\Program Files\Java\<jdkversion>")

    • Click "OK" and close all dialogs.

  3. Restart your IDE / Terminal. (do not skip this step)

这篇关于错误:未设置 JAVA_HOME 并且在您的 flutter PATH 中找不到“java"命令.扑腾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆