很多使用 Mac 电脑的小伙伴在加载 rJava 包或者一些依赖 rJava 包的 R 包,例如 xlsx 和 tabulizer 的时候会遇到如下错误:
![]()
经过昨天一晚上的折腾,发现这种错误出现的原因是 Java 安装错了!
通常我们都会直接从 https://java.com/zh-CN/ 上直接下载 Java 安装:
![]()
这样直接下载安装得到的是 JRE,安装好之后就会出现上述的报错,实际上应该从这里下载 JDK 安装:下载链接:https://download.oracle.com/java/17/latest/jdk-17_macos-aarch64_bin.dmg
从上面的 JDK 下载链接下载安装包安装完成再加载 rJava、xlsx、tabulizer 这些包就不会出错了。
关于 JRE 和 JDK 的区别:
JDK is a superset of JRE , and contains everything that is in JRE , plus tools such as the compilers and debuggers necessary for developing applets and applications. JRE provides the libraries, the Java Virtual Machine (JVM), and other components to run applets and applications written in the Java programming language. Note that the JRE includes components not required by the Java SE specification, including both standard and non-standard Java components.
Windows 电脑我没有测试过,估计也是安装 JDK 会更好些。
其中 xlsx 包在县域统计年鉴整理的课程中使用到过:

tabulizer 包在使用 R 语言提取 PDF 文档中的表格课程中使用过:
×
感兴趣的小伙伴可以前往学习~
点击这里跳转到 RStata 短书平台获取附件:Mac 上 R 语言安装 rJava、xlsx、tabulizer 等出错如何解决?
评论