无法为Eclipse StatEt插件安装rj软件包

时间:2018-08-25 06:59:14

标签: java r eclipse ubuntu statet

由于Ubuntu升级到18.04破坏了我的Eclipse配置,因此我重新安装了Eclipse(Photon Release 4.8.0),并尝试再次将R与StatET 3.6插件一起使用。按照建议的here,我尝试通过

在R term控制台中安装软件包rj-2.1
install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-2.1")

这开始安装rjrj.gd

Installing packages into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)

但以错误消息结尾:

Warning message:
In install.packages(c("rj", "rj.gd"), repos = "http://download.walware.de/rj-2.1") :
  installation of package ‘rj’ had non-zero exit status

仔细查看控制台输出会显示以下错误消息:

checking Java support in R... configure: error: cannot determine complete java config
    JAVA_HOME: /usr/lib/jvm/default-java
    JAVA     : /usr/lib/jvm/default-java/bin/java
    JAVAC    : /usr/lib/jvm/default-java/bin/javac
    JAVAH    : 
    JAVA_CPPFLAGS: -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux
    JAVA_LIBS: -L/usr/lib/jvm/default-java/lib/server -ljvm
    JAR      : /usr/lib/jvm/default-java/bin/jar
R is not configured with full Java support. Please make sure
an JDK is installed and run
    R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
    R CMD javareconf -e
to set all Java-related variables and then install the package.
ERROR: configuration failed for package ‘rj’
* removing ‘/usr/local/lib/R/site-library/rj’
* restoring previous ‘/usr/local/lib/R/site-library/rj’

当我运行建议的命令时

sudo R CMD javareconf

在终端中,输出表明它按预期工作

Java interpreter : /usr/lib/jvm/default-java/bin/java
Java version     : 10.0.2
Java home path   : /usr/lib/jvm/default-java
Java compiler    : /usr/lib/jvm/default-java/bin/javac
Java headers gen.: 
Java archive tool: /usr/lib/jvm/default-java/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux     -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-AitvI6/r-base-3.4.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
g++ -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/default-java/lib/server -ljvm -L/usr/lib/R/lib -lR


JAVA_HOME        : /usr/lib/jvm/default-java
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/lib/R
Done.

尽管如此,安装rj-2.1之后仍然会产生相同的错误消息。我查看了/usr/local/lib/R/site-library,并且rj.gd已更新,但是rj仍然是以前的版本。启动R控制台会产生错误消息

eclipse.buildId=4.8.0.I20180611-0500
java.version=10.0.2
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_GB
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.java.product

de.walware.statet.r.console.ui

Launching the R Console was cancelled, because it seems starting the R engine failed.
Please make sure that R package 'rj' (2.1 or compatible) is installed and that the R library paths are set correctly for the R environment configuration 

任何想法,如何安装rj

P.S .:似乎是Java版本问题。 Ubuntu 18.04已预安装此版本:

openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.1, mixed mode)

更新
现在无需进行任何更改就可以从rj控制台安装rj.gdRterm/usr/local/lib/R/site-library中的文件确实已更新,并且Rterm控制台没有任何错误消息。
但是,在创建和运行RJ控制台时,会出现相同的错误消息

Launching the R Console was cancelled, because it seems starting the R engine failed. 
Please make sure that R package 'rj' (2.1 or compatible) is installed and that the R library paths are set correctly for the R environment configuration 'Rstatet36'.

我也再次将Preferences>Statet>R environmentRun Configurations定义为无效。

更新:如果您对问题不满意,则添加评论(为什么这样做)将是有利的,因此可以改善问题。或删除。那好吧。

1 个答案:

答案 0 :(得分:1)

这确实是错误的Java环境。安装不需要花费很长时间,如果您知道,该怎么做,但是找出来却很繁琐:

1)使用sudo apt install openjdk-8-jdk在Ubuntu 18.04上安装openjdk 8。我认为只需使用sudo update-alternatives --config java更改默认Java版本可能会有所帮助,但事实并非如此。所以不要这样做。

2)转到Eclipse>首选项> Java>已安装的JRE: enter image description here 在此处选择ADD并指定文件夹,在本例中为/ usr / lib / jvm / java-8-opdenjdk-amd64。点击确定。

3)转到“运行”>“运行配置”,然后双击R console以打开新的运行配置。选择RJ (default)

enter image description here

4)转到标签JRE,然后从Alternate JRE中选择Java 8。 enter image description here

5)为您的新配置起一个漂亮的名字,单击ApplyRun,RJ控制台启动。至少在我的环境中确实如此。