java - R-项目 : xlsx package installation failure (due to java issues)

标签 java r xlsx rjava

我试图安装 xlsx 包,不幸的是,Java 有一个问题,我无法解决。

请在下面找到尝试安装包 xlsx 时产生的输出。

这是输出:


R version 3.1.1 (2014-07-10) -- "Sock it to Me"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> install.packages("xlsx")
Installing package into ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
also installing the dependencies ‘rJava’, ‘xlsxjars’

trying URL 'contrib/rJava_0.9-6.tar.gz'
Content type 'application/x-gzip' length 567515 bytes (554 Kb)
opened URL
==================================================
downloaded 554 Kb

trying URL 'contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 Mb)
opened URL
==================================================
downloaded 9.0 Mb

trying URL 'contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 Kb)
opened URL
==================================================
downloaded 305 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for string.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking whether time.h and sys/time.h may both be included... yes
configure: checking whether gcc -m64 -std=gnu99 supports static inline...
yes
checking whether setjmp.h is POSIX.1 compatible... yes
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/bin/java'
archiver    : '/bin/jar'
compiler    : '/bin/javac'
header prep.: '/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... 
Error: Could not find or load main class getsp
no
configure: error: Java interpreter '/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status
ERROR: dependency ‘rJava’ is not available for package ‘xlsxjars’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/xlsxjars’
Warning in install.packages :
  installation of package ‘xlsxjars’ had non-zero exit status
ERROR: dependencies ‘rJava’, ‘xlsxjars’ are not available for package ‘xlsx’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/xlsx’
Warning in install.packages :
  installation of package ‘xlsx’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpj1UG8a/downloaded_packages’

Java 已安装:

java -version 给出以下输出:

java version "1.7.0_71"
OpenJDK Runtime Environment (fedora-2.5.3.0.fc20-x86_64 u71-b14)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

“sudo R CMD javareconf”导致:

Java interpreter : /bin/java
Java version     : 1.7.0_71
Java home path   : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre
Java compiler    : /bin/javac
Java headers gen.: /bin/javah
Java archive tool: /bin/jar

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic  -c conftest.c -o conftest.o
gcc -m64 -std=gnu99 -shared -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR


JAVA_HOME        : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib64/R
Done.

尽管如此,install.packages('rJava') 导致:

checking Java support in R... present:
interpreter : '/bin/java'
archiver    : '/bin/jar'
compiler    : '/bin/javac'
header prep.: '/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/../include/linux'
java libs   : '-L/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71-2.5.3.0.fc20.x86_64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... 
Error: Could not find or load main class getsp
no
configure: error: Java interpreter '/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tamaspavlicek/R/x86_64-redhat-linux-gnu-library/3.1/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmpnl17m7/downloaded_packages’

我不知道如何解决这个 Java 问题。我使用 RStudio 和 Fedora。 非常感谢您的帮助。

谢谢

塔玛斯

最佳答案

如果您安装了 Java,请尝试从命令行重置 R 的 java 配置

sudo R CMD javareconf

然后再次尝试仅安装 rJava(您可以先重新启动 RStudio)

install.packages('rJava')

如果这仍然没有解决您的问题,则错误表明 R 无法加载 getsp。:

checking whether Java run-time works... 
Error: Could not find or load main class getsp

首先验证getsp是否可以访问。

locate getsp

输出可能包含多个项目,但您应该找到如下内容:

/usr/share/R/share/java/getsp.class

然后我们希望它可以访问,所以导出它以便 R 可以找到它:

export CLASSPATH=/usr/share/R/share/java

在同一窗口中,启动另一个 R session 并再次尝试安装 rJava

要休息的另一件事是 JAVA_HOME 并重新运行 javareconf

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64/jre
export PATH=$PATH:$JAVA_HOME/bin
sudo R CMD javareconf

还建议在 rJava issues取消设置 CLASSPATH因为它可能会导致其他问题。如果仍然不能解决问题,您可能应该在尝试更改 JAVA_HOME 之前执行此操作并再次重置。

编辑

鉴于这个问题在很长一段时间内一直“没有答案”,我认为我还应该添加我的建议以仅使用 readxl而不是使用 Java 的包。它安装起来更容易,并且是 tidyverse 的一部分。只是对尝试使用 Excel 文件的人的一般建议。

关于java - R-项目 : xlsx package installation failure (due to java issues),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26806776/

相关文章:

java - Jersey REST api 多个资源

java - Hive 中的 COLLECT_SET(),保留重复项?

R - 列出列表的列表

r - 优化代码以根据 data.table 的条件更新组中的以下行

ruby-on-rails - Axlsx_rails。一次设置多行的高度

php - 如何使用 php 将 .xlsx 文件转换为 .xml 文件?

java.lang.NoSuchMethodError : org. apache.poi.util.POILogger.log(ILjava/lang/Object;Ljava/lang/Throwable;)V

java - 在不使用包装类的情况下使用 Jackson 序列化 java 对象时维护子类型信息

java - 如何强制类的用户在 Android 中的 UI 线程之外使用它?

r - 如何将一列字符串转换为因子列表,使用正则表达式过滤值