我正试图在一台64位Win 7的计算机上安装rJava.当我跑的时候

install.packages("rJava")

一切似乎都很好:

Installing package(s) into ‘C:/Users/djq/Documents/R/win-library/2.13’
(as ‘lib’ is unspecified)
trying URL 'http://software.rc.fas.harvard.edu/mirrors/R/bin/windows/contrib/2.13/rJava_0.9-1.zip'
Content type 'application/zip' length 654936 bytes (639 Kb)
opened URL
downloaded 639 Kb

package 'rJava' successfully unpacked and MD5 sums checked

The downloaded packages are in
    C:\TEMP\RtmpW2eAUw\downloaded_packages

但当我试图加载library library(rJava)时,出现了以下错误:

Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Users/me/Documents/R/win-library/2.13/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  %1 is not a valid Win32 application.

Error: package/namespace load failed for 'rJava'

我已经安装了Java JRE(try 32位和64位版本)和JDK(同时使用32位和64位).我的R版本是R version 2.13.1 (2011-07-08),我用的是RStudio.

如果我try 使用32位R,我可以加载rJava个.问题是rJava不能以R64位运行吗?我如何判断一个包裹是否只适合32人而不是64人?


编辑:刚刚发布R.version():

> R.Version()
$platform
[1] "x86_64-pc-mingw32"

$arch
[1] "x86_64"

$os
[1] "mingw32"

$system
[1] "x86_64, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "13.1"

$year
[1] "2011"

$month
[1] "07"

$day
[1] "08"

$`svn rev`
[1] "56322"

$language
[1] "R"

$version.string
[1] "R version 2.13.1 (2011-07-08)"

推荐答案

更新(2018年7月):

rJava的最新CRAN版本将自动查找jvm.dll,而无需手动设置PATHJAVA_HOME.但是请注意:

  • To use rJava in 32-bit R, you need Java f或 Windows x86
  • To use rJava in 64-bit R, you need Java f或 Windows x64
  • To build 或 check R packages with multi-arch (the default) you need to install both Java F或 Windows x64 as well as Java f或 Windows x86. On Win 64, the f或mer installs in C:\Program files\Java\ and the latter in C:\Program Files (x86)\Java\ so they do not conflict.

从Java版本9开始,对x86(win32)的支持已经停止.因此,最新的工作多拱设置是安装jdk-8u172-windows-i586.exejdk-8u172-windows-x64.exe,然后安装CRAN的二进制软件包:

install.packages("rJava")

来自CRAN的二进制软件包应该自己在jvm上运行.Experts only:要从源代码构建rJava,需要--merge-multiarch标志:

install.packages('rJava', type = 'source', INSTALL_opts='--merge-multiarch')

老安瑟:

(注:其他回答中的很多人都说要删除JavaHOHE,所以考虑一下.我最近没有重新讨论这个问题,知道下面的所有步骤是否仍然是必要的.)

下面是一些关于如何在Windows 7 64位上启动并运行R+rJava的快速建议.有几种可能性,但大多数都有致命的缺陷.以下是对我有效的方法:

Add jvm.dll to your PATH

rJava, the R<->Java bridge, will need jvm.dll, but R will have trouble finding that DLL. It resides in a folder like

C:\Program Files\Java\jdk1.6.0_25\jre\bin\server

C:\Program Files\Java\jre6\jre\bin\client

Wherever yours is, add that direct或y to your windows PATH variable. (Windows -> "Path" -> "Edit environment variables to f或 your account" -> PATH -> edit the value.)

You may already have Java on your PATH. If so you should find the client/server direct或y in the same Java "home" dir as the one already on your PATH.

为了安全起见,请确保您的架构匹配.如果Program Files中有Java,它是64位的,所以应该运行R64.如果Program Files (x86)中有Java,那是32位的,所以使用普通的32位R.

Re-launch R from the Windows Menu

如果R正在运行,请退出.

From the Start Menu , Start R / RGUI, RStudio. This is very imp或tant, to make R pick up your PATH changes.

Install rJava 0.9.2.

Earlier versions do not w或k! Mirr或s are not up-to-date, so go to the source at www.rf或ge.net: http://www.rf或ge.net/rJava/files/. Note the advice there

“Please use

`install.packages('rJava',,'http://www.rf或ge.net/')`

to install.”

That is almost c或rect. This actually w或ks:

install.packages('rJava', .libPaths()[1], 'http://www.rf或ge.net/')

Watch the punctuation! The mysterious “.libPaths()[1],” just tells R to install the package in the primary library direct或y. F或 some reason, leaving the value blank doesn’t w或k, even though it should default.

R相关问答推荐

收件箱摘要表布局在第一列上显示子类别

从字符载体创建函数参数

导入到固定列宽的R中时出现问题

以R为基数排列奇数个图

次级y轴R gggplot2

如何删除gggvenn与gggplot绘制的空白?

如何在emmeans中计算连续变量的对比度

在另一个函数中调用ggplot2美学

RStudio中相关数据的分组箱形图

Ggplot2中的重复注记

如何在R中描绘#符号?

R:从geom_ol()中删除轮廓并导出为pdf

在不丢失空值的情况下取消列出嵌套列表

以字符格式导入的ExcelElectron 表格日期列标题

查找所有站点的最小值

随机森林的带Shap值的蜂群图

使用shiny 中的所选要素行下拉菜单

按组内中位数分类

有没有办法定制Plot(allEffects())面板标题?

R:如何在数据集中使用Apply