Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can rJava install openjdk during the installation? #332

Open
moomoofarm1 opened this issue Sep 11, 2024 · 5 comments
Open

Can rJava install openjdk during the installation? #332

moomoofarm1 opened this issue Sep 11, 2024 · 5 comments

Comments

@moomoofarm1
Copy link

As stated in the title.

@e-kotov
Copy link

e-kotov commented Sep 13, 2024

@s-u
Copy link
Owner

s-u commented Sep 15, 2024

I don't see this a something that it should do. The user should install whichever Java version(s) they intended to use - rJava should not make the call. The only option I could see is if no JRE is found at initialization time then to either point to a way to install it or offer a local installation after a prompt with version options (sadly, Java has descended into the Python nightmare world by constantly breaking compatibility so you have to carefully select the version that works with the code you intend to run). rJava was originally designed to provided consistent support for R, so it is no different than other tools like compilers and libraries in R that needs to be present before they are used.

That said, there is an issue on allowing run-time loads of JVM (see #334) - so in that world it would make it more sense to allow run-time installs, but that is different from this issue.

@moomoofarm1
Copy link
Author

Thanks for the answers.
I would really appreciate it if the package can install it automatically and keep the installation underneath. R users like me are not familiar with the details.

@e-kotov
Copy link

e-kotov commented Oct 4, 2024

@moomoofarm1, the problem is, there are multiple versions of Java that may be required by various packages that you use. So you have to decide which Java version you need to install by reading the recommendations in the package documentation. The author of a particular package may provide you with instructions on how to install the exact version of Java that you need to use their package. For example, this is something the authors of {r5r} have done here. They rely on {rJavaEnv} to quickly install the Java they need (version 21) for {r5r} to work.

So even if {rJava} would have a function to install Java, you would still need to do a little bit of work.

If you want the easiest method that will take into account your OS and processor type, please do:

install.packages('rJavaEnv')
rJavaEnv::java_quick_install(version = 21)

Or whichever Java version you need depending on the package you plan to use.

Preferably, restart R after doing this. If you are on Linux (or on macOS/Windows, but you chose to install packages from source), you may need to remove {rJava} first, install Java as I noted above, and then re-install {rJava}.

@yudalang3
Copy link

I can not agree with more, becase annother package doing this job is appropriate. If you must do this, I recommand therJavaEnv package.

And I really , recommand to install the Java manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants