'WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE

what happend: i can't solve the warnings

fjw@MacBook-Pro googletest % [master] bazel info
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE.
bazel-bin: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/execroot/com_google_googletest/bazel-out/darwin_arm64-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/execroot/com_google_googletest/bazel-out/darwin_arm64-fastbuild/bin
bazel-testlogs: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/execroot/com_google_googletest/bazel-out/darwin_arm64-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/command.log
committed-heap-size: 75MB
execution_root: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/execroot/com_google_googletest
gc-count: 6
gc-time: 47ms
install_base: /var/tmp/_bazel_fjw/install/c32a815cda11aa2a78b80c4fc673e210
java-home: /Library/Java/JavaVirtualMachines/jdk-18.0.1.jdk/Contents/Home
java-runtime: Java(TM) SE Runtime Environment (build 18.0.1+10-24) by Oracle Corporation
java-vm: Java HotSpot(TM) 64-Bit Server VM (build 18.0.1+10-24, mixed mode, sharing) by Oracle Corporation
max-heap-size: 4294MB
output_base: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3
output_path: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/execroot/com_google_googletest/bazel-out
package_path: %workspace%
release: release 5.1.1-homebrew
repository_cache: /var/tmp/_bazel_fjw/cache/repos/v1
server_log: /private/var/tmp/_bazel_fjw/a826f32507803e99352fd6b3b40ddfa3/java.log.macbook-pro.fjw.log.java.20220514-122515.34242
server_pid: 34242
used-heap-size: 24MB
workspace: /Users/fjw/repositories/googletest
fjw@MacBook-Pro googletest % [master] mvn -v
Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)
Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec
Java version: 18.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-18.0.1.jdk/Contents/Home
Default locale: zh_CN_#Hans, platform encoding: UTF-8
OS name: "mac os x", version: "12.3.1", arch: "aarch64", family: "mac"

How can I solve the warning? I understand that I have configured the environment variable correctly



Solution 1:[1]

I believe you might have installed bazel via homebrew. Above issue is due to the fact that the homebrew version of the bazel installation is being picky about the specific location of the JDK. But you can resolve by try installing Bazel other than via homebrew.

You can also try setting the JAVA_HOME path in your Machine by using any of the below.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/bin
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sunil Gowroji