【发布时间】:2019-03-31 09:59:08
【问题描述】:
我正在尝试在我的 Java 应用程序中使用 Rjava,这需要在计算机中安装 R。
该应用程序在 IDE (IntelliJ IDEA) 中运行时运行良好,但是当我将它打包到 JAR 文件中并使用 java -jar myfile.jar 运行它时,我收到以下错误:
R_HOME is not set. Please set all required environment variables before running this program.
Unable to start R
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f847c3a470c, pid=4232, tid=4233
#
# JRE version: OpenJDK Runtime Environment (10.0.2+13) (build 10.0.2+13)
# Java VM: OpenJDK 64-Bit Server VM (10.0.2+13, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libR.so+0x17270c]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e" (or dumping to /home/xvlaze/IdeaProjects/Ypsilon/out/artifacts/Ypsilon/core.4232)
#
# An error report file with more information is saved as:
# /home/xvlaze/IdeaProjects/Ypsilon/out/artifacts/Ypsilon/hs_err_pid4232.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)
当然,这是因为我没有在 IDEA Artifact 中将 $R_HOME 设置为环境变量(我也不知道该怎么做)。 $R_HOME 在我的项目环境变量中指向/usr/lib64/R,但JAR 似乎看不到它。
现在,我想到的问题是:我应该在我的 JAR 中包含 /usr/lib64/R 的内容以使其工作还是有其他我不知道的方法?
【问题讨论】:
-
命令
echo $R_HOME的结果是什么? -
@AnarAmrastanov 什么都没有。但是,如果我运行
R RHOME,我会得到/usr/lib64/R。 -
我认为你应该设置那个环境变量。请看我的回答
标签: java r intellij-idea jar rjava