如何运行 jar 文件中的 R 脚本
我有 Java 应用程序,它部署为 jar 并通过调用 main 函数从 cmd 行运行。有一些用 R 编写的与应用程序相关的工具随应用程序一起分发。
我想启用从 cmd 行或从 Java 调用 jar 文件中的 R 脚本。
当 R 脚本位于 jar 文件中时(无需解压缩 jar 文件),如何从 cmd 行或 Java 执行 R 脚本。
I have Java application that is deployed as a jar and run from a cmd line by calling a main function. There are some tools that are written in R associated with the application that are distributed with the application.
I'd like to enable calling the R scripts that are in the jar file from either the cmd line or from Java.
How can I execute an R script from either the cmd line or Java when the R script is in a jar file (with out unzipping the jar file).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过获取 R 脚本的
InputStream
并读取文件内容来访问 R 脚本:我建议您详细了解 JAR 的打包以及如何包含/存储资源。
有了 R 脚本的内容,您可以使用本文中提到的方法来执行它(使用库执行 R)。
You can access the R script by getting an
InputStream
for it and reading the file content:I'd recommend reading more into the packing of JARs and how to include/store resources.
With the contents of the R script, you can execute it using approaches such as the one mentioned in this article (using libraries to execute R).