tabulapdf icon indicating copy to clipboard operation
tabulapdf copied to clipboard

easier way to install Java for your users with rJavaEnv

Open e-kotov opened this issue 1 year ago • 2 comments

Prework

Question

Please consider testing my new package rJavaEnv that manages Java install in one swift command: rJavaEnv::java_quick_install(version = 21)

This package has already helped to hold a recent workshop on r5r package that is also dependent on rJava (see feedback https://github.com/e-kotov/rJavaEnv/issues/6#issuecomment-2184249625).

Ultimately, your users on any OS will have less Java related issues and questions in your Issues section.

Reproducible example

if (!requireNamespace("remotes", quietly = TRUE)) {
  install.packages("remotes")
}
remotes::install_github("e-kotov/rJavaEnv")

rJavaEnv::java_quick_install(version = 21)

java_version_check_rjava()

This will:

  • download Java 21 distribution compatible with the current operating system and processor architecture into a local cache folder;

  • extract the downloaded Java distribution into another cache folder;

  • create a symbolic link (for macOS and Linux) or junction (for Windows, if that fails, just copies the files) rjavaenv/platform/processor_architecture/java_version in the current directory/project to point to the cached installation;

  • set the current session’s JAVA_HOME and PATH environment variables to point to the installed (symlinked) Java distribution

  • add code to .Rprofile file in the current directory/project to set JAVA_HOME and PATH environment variables when the project is opened in RStudio. This way a user has no opportunity to invoke a function that initialises rJava before the correct paths are set.

e-kotov avatar Jun 27 '24 15:06 e-kotov

@e-kotov thanks a lot for sending this

I will inspect the code and decide about it.

In the meanwhile, you should consider sending a draft to the Journal of Open Source Software. Check this example https://www.theoj.org/joss-papers/joss.02769/10.21105.joss.02769.pdf

pachadotdev avatar Jun 27 '24 17:06 pachadotdev

@pachadotdev

The package is not on CRAN yet. I am reaching out for feedback to package developers like you in advance, while I can still make breaking changes. A few things still need to be tested, esp. on Linux, as you might notice in the Issues section.

Thanks for the tip about the journal!

e-kotov avatar Jun 27 '24 19:06 e-kotov

@pachadotdev thanks again for your PR to {rJavaEnv}. I put you on the contributors list too.

It's on ~~the AppStore~~ CRAN now.

install.packages("rJavaEnv")

Due to CRAN policies, on first run I ask the user for consent. This can be skipped with additional command before the Java install command:

rje_consent(provided = TRUE)
java_quick_install(version = 21)

So feel free to suggest it to {tabulapdf} users.

e-kotov avatar Aug 26 '24 19:08 e-kotov