configure: error: 无法找到JDK Headers问题求助(已装OpenJDK 8)
Hey there, fellow tech newbie! Sorry you're stuck on this error—let's work through getting this sorted out for you, since you already have OpenJDK 8 installed. Here are the key steps to fix it:
Install the OpenJDK 8 Development Package
Chances are you only installed the JRE (Java Runtime Environment) instead of the full JDK, which includes the header files needed for compilation. On Debian/Ubuntu-based systems, run these commands to install the required development package:sudo apt update sudo apt install openjdk-8-jdkThis package will add all the JDK header files (like
jni.h) that your configure script is looking for.Verify and Fix Your JAVA_HOME Path
You mentioned your JAVA_HOME isusr/lib/jvm/java-8-openjdk-amd64—note that this is missing a leading slash (/), which is critical for absolute paths. The correct path should be/usr/lib/jvm/java-8-openjdk-amd64.First, check if the headers exist in this path:
ls /usr/lib/jvm/java-8-openjdk-amd64/includeIf you see files like
jni.handjni_md.h, the headers are there—great! Now make sure your JAVA_HOME is set correctly:- Open your bash profile (e.g.,
~/.bashrc) with a text editor:nano ~/.bashrc - Add these lines at the end of the file:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 export PATH=$JAVA_HOME/bin:$PATH - Save and exit, then reload the profile to apply changes:
source ~/.bashrc
- Open your bash profile (e.g.,
Manually Specify JDK Path to Configure
If the above steps don't resolve the error, you can explicitly tell the configure script where to find the JDK. Try running configure with either of these flags:./configure --with-java-home=$JAVA_HOMEOr directly point to the include directory:
./configure --with-jdk-include-dir=$JAVA_HOME/include
If you still run into issues, double-check that your system architecture (amd64) matches your JDK version (you already have the amd64 build, so this should be fine) and that your configure script doesn't have any custom Java-related flags that might be conflicting.
内容的提问来源于stack exchange,提问作者Dexter

