java 加载rJava包时java路径错误

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

Error of java path on loading rJava package

javarunixrjava

提问by Aman Mathur

I am trying to load 'rJava' package in my Unix machine. Before loading I have set the path using

我正在尝试在我的 Unix 机器中加载“rJava”包。在加载之前我已经使用设置了路径

Sys.setenv("JAVA_HOME= myfilepath") 

in my R script.

在我的 R 脚本中。

Despite this I am getting the following error (Below is the part of the error):

尽管如此,我还是收到了以下错误(以下是错误的一部分):

checking Java support in R... present:
interpreter : '/usr/lib/jvm/jre/bin/java'
archiver    : '/usr/lib/jvm/jre/../bin/jar'
compiler    : '/usr/lib/jvm/jre/../bin/javac'
header prep.: '/usr/lib/jvm/jre/../bin/javah'
cpp flags   : '-I/usr/lib/jvm/java/include I/usr/lib/jvm/java/include/linux'
java libs   : '-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3729: /usr/lib/jvm/jre/bin/java: No such file or directory
no configure: error: Java interpreter '/usr/lib/jvm/jre/bin/java' does not work

As you can see the error shows that /usr/lib/jvm/jre/bin/java: No such file or directory. But I have not set this as myfilepath. How do I prevent the installer from looking at this path?

如您所见,错误显示/usr/lib/jvm/jre/bin/java: No such file or directory。但我没有将其设置为myfilepath。如何防止安装程序查看此路径?

Kindly help.

请帮助。

回答by Sushant Gupta

sudo R CMD javareconf

This works perfectly. Keeping this here if someone reads this in future.

这完美地工作。如果将来有人阅读此内容,请将其保留在此处。

回答by Colonna Maurizio

I have a VM of Ubuntu 14.04 LTS on VirtualBox, and the real path of installation of my java-jdk is the following :

我在 VirtualBox 上有一个 Ubuntu 14.04 LTS 的虚拟机,我的 java-jdk 的实际安装路径如下:

/usr/lib/jvm/java-7-openjdk-amd64

This command worked very fine for my situation. I had this type of error from installation o rJava package on RStudio:

这个命令非常适合我的情况。我在 RStudio 上安装或 rJava 包时遇到了这种类型的错误:

*./configure: line 3736: /usr/lib/jvm/default-java/jre/bin/java: No such file or directory*

First I' have modified the profile in this way : sudo gedit /etc/profile and then added this instructions at the eof:

首先,我以这种方式修改了配置文件:sudo gedit /etc/profile,然后在 eof 中添加了以下说明:

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

After this, from terminal session I've typed the command:

在此之后,从终端会话我输入了命令:

sudo R CMD javareconf

and the package rJava was successfully installed.

并且包 rJava 已成功安装。

Note: You might also have to set the LD_LIBRARY_PATHenvironment variable, before running sudo R CMD javareconf.

注意:您可能还必须在运行之前设置LD_LIBRARY_PATH环境变量sudo R CMD javareconf

回答by MItrajyoti Kusari

Faced same problem in Ubuntu 14.04. This installation guide was helpful for me after going through a straightforward installation. http://www.korecky.org/?p=1254(Installation of R) and [http://www.korecky.org/?p=847](Installation of Java)

在 Ubuntu 14.04 中遇到同样的问题。经过简单的安装后,本安装指南对我很有帮助。 http://www.korecky.org/?p=1254(R 的安装)和 [ http://www.korecky.org/?p=847](Java 的安装)