Reputation: 30615
I'm encountering a CMake error suggesting it cannot find Java (JDK I think?):
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?
Upvotes: 1
Views: 7634
Reputation: 2303
In my case I have been able to solve it including the correct JAVA_HOME path (I used the java version installed by Android Studio), and its bin directory in the PATH variable:
JAVA_HOME=/home/user/Applications/android-studio/jbr
export PATH=$PATH:$JAVA_HOME/bin
Upvotes: 0
Reputation: 1
I can confirm the approach by caifeng-zhu worked for me, even though the CMake
error I got, arised in the attempt to compile ceph-libs (17.2.5-6), was slightly different:
Could NOT find Java (missing: Java_JAVAC_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVADOC_EXECUTABLE Development) (found version "11.0.18")
I solved it by modifying /usr/share/cmake/Modules/FindJava.cmake
only in its _JAVA_PATHS
section, by adding the Java's explicit folder location found in my packet manager (but I also could have used whereis java
). In my case a more recent Java version was installed (19.0.2.u7-2), so I added a line to FindJava.cmake pointing to this latter one.
My configuration is:
Upvotes: 0
Reputation: 21
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 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
. It is found that
_JAVA_HINTS
and _JAVA_PATHS
do not include my java version.
solution:
Use a new version CMake that supports my java version
Upvotes: 2
Reputation: 111329
It looks like cmake is looking for javah
not javac
. You're using Java 1.8, so you should have javah installed. (It has been removed in a later version, and instead of javah
you're supposed to use 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)
Upvotes: 2