cómo hacer jni.h ser encontrado?


En Ubuntu 12.04, tengo jdk7 de sun/oracle instalado. Cuando locate jni.h, imprime múltiples ubicaciones

/usr/lib/jvm/java-6-openjdk-amd64/include/jni.h
/usr/lib/jvm/jdk1.7.0_07/include/jni.h
...

En el archivo de cabecera generado por JDK, hay include <jni.h>, y actualmente se queja

fatal error: jni.h: No such file or directory.

En mi Makefile, no hay especificación de ubicaciones donde jni.h está. Y estoy preguntando si es posible configurar cierto parámetro del sistema para hacer que la ruta de jni.h (digamos, /usr/lib/jvm/jdk1.7.0_07/include/jni.h) se conozca cuando se compila.

Author: Richard, 2013-01-26

7 answers

Tienes que decirle a tu compilador dónde está el directorio include. Algo como esto:

gcc -I/usr/lib/jvm/jdk1.7.0_07/include

Pero depende de tu makefile.

 25
Author: jdb,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-01-25 20:25:16

Necesita ambos archivos jni.h y jni_md.h, Prueba esto

gcc -I/usr/lib/jvm/jdk1.7.0_07/include \
  -I/usr/lib/jvm/jdk1.7.0_07/include/linux filename.c

Esto incluirá tanto los archivos JNI amplios como los necesarios para linux

 18
Author: yogesh singh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-22 21:20:38

Instalar el Kit de Desarrollo de OpenJDK (JDK) debería solucionar el problema.

sudo apt-get install openjdk-X-jdk

Esto debería permitirle compilar sin problemas.

 12
Author: hgaronfolo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-13 08:33:27

Utilice el siguiente código:

make -I/usr/lib/jvm/jdk*/include

Donde jdk * es el nombre del directorio de su instalación jdk (por ejemplo, jdk1. 7. 0).

Y no habría una solución para todo el sistema ya que el nombre del directorio sería diferente con diferentes compilaciones de JDK descargadas e instaladas. Si desea una solución automatizada, incluya todos los comandos en un solo script y ejecute dicho script en Terminal.

 6
Author: user2925073,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-27 12:58:12

Establecer JAVA_INCLUDE_DIR en donde jni.h se encuentra debe resolver su problema (configuración CPPFLAGS no funcionó para mí)

Asumiendo que es /usr / lib64 / java/include;

export JAVA_INCLUDE_DIR=/usr/lib64/java/include
 2
Author: karanis,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-24 21:27:35

Ninguna de las soluciones publicadas funcionó para mí.

Tuve que vi en mi Makefile y editar la ruta para que la ruta a la carpeta include y el subsistema del sistema operativo (en mi caso, -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux) fuera correcta. Esto me permitió ejecutar make y make install sin problemas.

 1
Author: bphilipnyc,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-02-27 07:34:14

Normalmente defino mi variable JAVA_HOME así:

export JAVA_HOME=/usr/lib/jvm/java/

Allí están los archivos include necesarios. A veces agrego lo siguiente a mi .barshrc cuando compilo un montón de cosas que lo necesitan.

 0
Author: Leo Ufimtsev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-03 18:37:36