[英]CMake cannot find Java on Linux “Could NOT find Java (missing: Java_JAVAH_EXECUTABLE)”
I'm encountering a CMake error suggesting it cannot find Java (JDK I think?):我遇到了 CMake 错误,提示找不到 Java(我认为是 JDK?):
Could NOT find Java (missing: Java_JAVAH_EXECUTABLE) (found version
"1.8.0_181")
However, when I run:但是,当我运行时:
which javac
I get:我得到:
/bin/javac
but setting:但设置:
export JAVA_HOME=/bin/javac
and re-compiling does not solve the problem.并且重新编译并不能解决问题。
Anybody encountered this before?有人遇到过这个吗?
It looks like cmake is looking for javah
not javac
.看起来 cmake 正在寻找
javah
而不是javac
。 You're using Java 1.8, so you should have javah installed.您使用的是 Java 1.8,因此您应该安装 javah。 (It has been removed in a later version, and instead of
javah
you're supposed to use javac -h
) (它已在以后的版本中被删除,而不是
javah
你应该使用javac -h
)
Make sure cmake can find the javah tool by setting JAVA_HOME so that it points at the Java 8 installation directory (typically under /usr/lib/jvm on a Linux system)确保 cmake 可以通过设置 JAVA_HOME 找到 javah 工具,使其指向 Java 8 安装目录(通常在 ZEDC9F0A5A5D577973818E37367 系统上的 /usr/lib/jvm 下)
I have encountered the same problem, but with a different cause.我遇到了同样的问题,但原因不同。 I post my problem and solution below, hoping to save others' troubleshooting time.
我在下面发布我的问题和解决方案,希望节省其他人的故障排除时间。
problem:问题:
The CMake
reported an error much like the thread title: CMake
报告了一个很像线程标题的错误:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find Java (missing: Java_JAVAH_EXECUTABLE) (found version
"11.0.7")
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindJava.cmake:191 (find_package_handle_standard_args)
CMakeLists.txt:20 (find_package)
analysis:分析:
Look at the file /usr/share/cmake/Modules/FindJava.cmake
.查看文件
/usr/share/cmake/Modules/FindJava.cmake
。 It is found that _JAVA_HINTS
and _JAVA_PATHS
do not include my java version.发现
_JAVA_HINTS
和_JAVA_PATHS
不包括我的java版本。
solution:解决方案:
Use a new version CMake that supports my java version使用支持我的 java 版本的新版本CMake
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.