Java 如何在 Ubuntu 中为 JNI C/C++ 库查找 JDK 目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16301074/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 06:13:38  来源:igfitidea点击:

How to find JDK directory in Ubuntu for JNI C/C++ library

javanetbeansdirectoryjvmjava-native-interface

提问by Habibullah Araphat Konok

I am trying to use JNI for my recent project. MY IDE is NetBeans. After creating C/C++ project , I am trying to add JDK directory from project properties->C compiler->include directory. I could not find any include or include/linux directory in /usr/lib/jvm/ directory.

我正在尝试将 JNI 用于我最近的项目。我的 IDE 是 NetBeans。创建 C/C++ 项目后,我尝试从项目属性->C 编译器->包含目录中添加 JDK 目录。我在 /usr/lib/jvm/ 目录中找不到任何 include 或 include/linux 目录。

Where should i look for "include" or "include/linux" directory?

我应该在哪里寻找“include”或“include/linux”目录?

采纳答案by GooseSerbus

Assuming you've got a JDK installed the directory should be something like: /usr/lib/jvm/java-7-openjdk-amd64(assuming OpenJDK 7 here). You might also need to a JAVA_HOMEenvironment variable pointing at the same directory depending on your build process.

假设你已经安装了 JDK,目录应该是这样的:(/usr/lib/jvm/java-7-openjdk-amd64假设这里是 OpenJDK 7)。JAVA_HOME根据您的构建过程,您可能还需要一个指向同一目录的环境变量。

If you haven't got a JDK installed you can install the OpenJDK with something like the following in a terminal windows:

如果您还没有安装 JDK,您可以在终端窗口中使用以下内容安装 OpenJDK:

sudo apt-get install openjdk-7-jdk