dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
105 stars 36 forks source link

[jni] Could NOT find Java (missing: Java_JAVAH_EXECUTABLE) #1276

Closed HosamHasanRamadan closed 2 weeks ago

HosamHasanRamadan commented 2 weeks ago

Windows 11 ARM Issue: flutter run -d windows

CMake Error at D:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Java (missing: Java_JAVAH_EXECUTABLE)
Call Stack (most recent call first):
  D:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  D:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/FindJava.cmake:326 (find_package_handle_standard_args)
  flutter/ephemeral/.plugin_symlinks/jni/src/CMakeLists.txt:31 (find_package)

Building Windows application...                                    688ms
Error: Unable to generate build files

java -version

openjdk version "17.0.11" 2024-04-16 LTS
OpenJDK Runtime Environment Microsoft-9388408 (build 17.0.11+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-9388408 (build 17.0.11+9-LTS, mixed mode, sharing)

echo %JAVA_HOME%

C:\Program Files\Microsoft\jdk-17.0.11.9-hotspot\
Flutter doctor ```console [√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [Version 10.0.22631.3737], locale en-US) • Flutter version 3.22.2 on channel stable at D:\flutter_windows_3.22.2-stable\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 761747bfc5 (5 weeks ago), 2024-06-05 22:15:13 +0200 • Engine revision edd8546116 • Dart version 3.4.3 • DevTools version 2.34.3 [√] Windows Version (Installed version of Windows is version 10 or higher) [X] Android toolchain - develop for Android devices X Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location. [X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.3) • Visual Studio at D:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.10.35013.160 • Windows 10 SDK version 10.0.22621.0 [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). [√] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.3737] • Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.87 [√] Network resources • All expected network resources are available. ! Doctor found issues in 3 categories. ```
HosseinYousefi commented 2 weeks ago

Follow the instructions here: https://github.com/dart-lang/native/blob/main/pkgs/jnigen/README.md#java-tooling

On windows, you must add $JAVA_HOME\bin\server to path.

HosseinYousefi commented 2 weeks ago

Did it solve your issue?

HosamHasanRamadan commented 2 weeks ago

Yes, Thanks @HosseinYousefi