java 无法编译 JNI 程序 rJava

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17570586/
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-11-01 02:21:30  来源:igfitidea点击:

unable to compile JNI program rJava

javar

提问by user2523848

I want to install rJava but it doesnt work. When I am typing R CMD javareconf in the console I get the following error:

我想安装 rJava 但它不起作用。当我在控制台中输入 R CMD javareconf 时,出现以下错误:

trying to compile and link a JNI progam
detected JNI cpp flags    :
detected JNI linker flags :
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -O3 -pipe  -g 
-c conftest.c -o conftest.o
conftest.c:1:17: error: jni.h: No such file or directory
conftest.c: In function 'main':
conftest.c:4: warning: implicit declaration of function 'JNI_CreateJavaVM'
make: *** [conftest.o] Error 1
Unable to compile a JNI program


Java library path:
JNI cpp flags    :
JNI linker flags :
Updating Java configuration in /usr/lib64/R
Done.

Any ideas how to fix it?

任何想法如何解决它?

采纳答案by Lo?a

The jni.hfile is part of JDK installation. You probably don't have Java JDK installed correctly. Download Oracle Java from here, or use your package manager.

jni.h文件是 JDK 安装的一部分。您可能没有正确安装 Java JDK。从此处下载 Oracle Java ,或使用您的包管理器。

If you have Java JDK already installed, set JAVA_HOME environment variable to point to the JDK directory.

如果您已经安装了 Java JDK,请将 JAVA_HOME 环境变量设置为指向 JDK 目录。

回答by Dr. Mike

I know this is closed but I'm adding my solution for completeness. In effect I had the same problem and all was correctly installed. I had also run the

我知道这已经关闭,但为了完整性,我正在添加我的解决方案。实际上,我遇到了同样的问题,并且都正确安装了。我也运行了

sudo R CMD javareconf

for system wide setting. What I needed was for it to work for my user. And in this case you should run

用于系统范围的设置。我需要的是让它为我的用户工作。在这种情况下,你应该运行

R CMD javareconf -e

without sudo and with appended -e.

没有 sudo 并附加 -e。

Worked for me. :)

对我来说有效。:)

回答by Santosh Garole

I was also facing same error which was on RHEL8.1 & i resolved it as follows:

我也遇到了 RHEL8.1 上的相同错误,我按如下方式解决了它:

 yum --enablerepo=* install java-1.8* 

later i ran same command which was giving me error logs of R server.

后来我运行了相同的命令,它给了我 R 服务器的错误日志。

 R CMD javareconf

which turns into the following output & succeed.

变成以下输出并成功。

enter image description here

在此处输入图片说明