You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

更新OpenJDK@17至17.0.15后Flutter Doctor仍使用旧Java路径的问题求助

更新OpenJDK@17至17.0.15后Flutter Doctor仍使用旧Java路径的问题求助

各位开发大佬们好,我完全是个开发新手,最近刚更新了OpenJDK@17到17.0.15版本,结果遇到了个搞不定的问题:

我检查了自己的JAVA_HOME路径是正确的,本地执行java相关命令也显示版本是17.0.15,但跑flutter doctor -v的时候,它还是在指向旧的Java路径,还报错说没法执行那个旧路径下的java文件来检测版本。求大家帮忙看看怎么解决这个问题,感激不尽!

flutter doctor -v 输出

[✓] Flutter (Channel stable, 3.27.4, on macOS 15.3 24D60 darwin-arm64, locale en-US)
    • Flutter version 3.27.4 on channel stable at /Users/apple/Documents/Development/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d8a9f9a52e (3 months ago), 2025-01-31 16:07:18 -0500
    • Engine revision 82bd5b7209
    • Dart version 3.6.2
    • DevTools version 2.40.3

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    • Android SDK at /Users/apple/Library/Android/sdk
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.13/libexec/openjdk.jdk/Contents/Home/ bin/java
    ✗ Cannot execute /opt/homebrew/Cellar/openjdk@17/17.0.13/libexec/openjdk.jdk/Contents/Home/ bin/java to determine the version

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.99.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (3 available)
    • macOS (desktop) • macos • darwin-arm64 • macOS 15.3 24D60 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3 24D60 darwin-arm64
    • Chrome (web) • chrome • web-javascript • Google Chrome 135.0.7049.115

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

本地Java环境检查结果

java -version
openjdk version "17.0.15" 2025-04-15
OpenJDK Runtime Environment Homebrew (build 17.0.15+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.15+0, mixed mode, sharing)

javac -version
javac 17.0.15

which java
/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home/bin/java

which javac
/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home/bin/javac

JAVA_HOME
/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 14:52:58