{"id":15051471,"url":"https://github.com/e-kotov/rjavaenv","last_synced_at":"2025-08-12T16:40:24.378Z","repository":{"id":241965040,"uuid":"803472511","full_name":"e-kotov/rJavaEnv","owner":"e-kotov","description":"Java Environments for R Projects","archived":false,"fork":false,"pushed_at":"2025-05-26T14:12:21.000Z","size":9923,"stargazers_count":19,"open_issues_count":15,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-05T03:47:50.974Z","etag":null,"topics":["environments","java","r","reproducibility","reproducible-research"],"latest_commit_sha":null,"homepage":"http://www.ekotov.pro/rJavaEnv/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/e-kotov.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":"codemeta.json","zenodo":null}},"created_at":"2024-05-20T19:40:36.000Z","updated_at":"2025-06-30T02:08:12.000Z","dependencies_parsed_at":"2024-05-30T23:36:06.003Z","dependency_job_id":"c40d3bf4-cafb-4dc9-bd81-ce5bd7fd0ae3","html_url":"https://github.com/e-kotov/rJavaEnv","commit_stats":{"total_commits":253,"total_committers":4,"mean_commits":63.25,"dds":0.04347826086956519,"last_synced_commit":"49ab66591c6e129be24df717231d4b70f076bd06"},"previous_names":["e-kotov/rjavaenv"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/e-kotov/rJavaEnv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2FrJavaEnv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2FrJavaEnv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2FrJavaEnv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2FrJavaEnv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-kotov","download_url":"https://codeload.github.com/e-kotov/rJavaEnv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-kotov%2FrJavaEnv/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270099288,"owners_count":24527027,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["environments","java","r","reproducibility","reproducible-research"],"created_at":"2024-09-24T21:35:47.444Z","updated_at":"2025-08-12T16:40:24.337Z","avatar_url":"https://github.com/e-kotov.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n# rJavaEnv: Java Environments for R Projects \u003ca href=\"https://www.ekotov.pro/rJavaEnv/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"134\" alt=\"rJavaEnv website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![Project Status:\nActive](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n\u003ca href=\"https://lifecycle.r-lib.org/articles/stages.html#stable\"\ntarget=\"_blank\"\u003e\u003cimg\nsrc=\"https://img.shields.io/badge/lifecycle-stable-brightgreen.svg\"\nalt=\"Lifecycle: stable\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://CRAN.R-project.org/package=rJavaEnv\"\ntarget=\"_blank\"\u003e\u003cimg src=\"https://www.r-pkg.org/badges/version/rJavaEnv\"\nalt=\"CRAN status\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://CRAN.R-project.org/package=rJavaEnv\"\ntarget=\"_blank\"\u003e\u003cimg\nsrc=\"https://cranlogs.r-pkg.org/badges/grand-total/rJavaEnv?color=blue\"\nalt=\"CRAN/METACRAN Total downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://CRAN.R-project.org/package=rJavaEnv\"\ntarget=\"_blank\"\u003e\u003cimg\nsrc=\"https://cranlogs.r-pkg.org/badges/rJavaEnv?color=blue\"\nalt=\"CRAN/METACRAN Downloads per month\" /\u003e\u003c/a\u003e\n[![R-CMD-check](https://github.com/e-kotov/rJavaEnv/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/e-kotov/rJavaEnv/actions/workflows/R-CMD-check.yaml)\n\u003c!-- [![pkgcheck](https://github.com/e-kotov/rJavaEnv/workflows/pkgcheck/badge.svg)](https://github.com/e-kotov/rJavaEnv/actions?query=workflow%3Apkgcheck) --\u003e\n[![codecov](https://codecov.io/github/e-kotov/rJavaEnv/graph/badge.svg?token=2UKGZVNO5V)](https://app.codecov.io/github/e-kotov/rJavaEnv)\n\n[![DOI](https://zenodo.org/badge/DOI/10.32614/CRAN.package.rJavaEnv.svg)](https://doi.org/10.32614/CRAN.package.rJavaEnv)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11403009.svg)](https://doi.org/10.5281/zenodo.11403009)\n\n\u003c!-- badges: end --\u003e\n\nQuickly install `Java Development Kit (JDK)` without administrative\nprivileges and set environment variables in current R session or project\nto solve common issues with ‘Java’ environment management in ‘R’.\nRecommended to users of `Java`/`{rJava}`-dependent `R` packages such as\n`{r5r}`, `{opentripplanner}`, `{xlsx}`, `{openNLP}`, `{rWeka}`,\n`{RJDBC}`, `{tabulapdf}`, and many more. `{rJavaEnv}` prevents common\nproblems like `Java` not found, `Java` version conflicts, missing `Java`\ninstallations, and the inability to install `Java` due to lack of\nadministrative privileges. `{rJavaEnv}` automates the download,\ninstallation, and setup of the `Java` on a per-project basis by setting\nthe relevant `JAVA_HOME` in the current `R` session or the current\nworking directory (via `.Rprofile`, with the user’s consent). Similar to\nwhat `{renv}` does for `R` packages, `{rJavaEnv}` allows different\n`Java` versions to be used across different projects, but can also be\nconfigured to allow multiple versions within the same project (e.g. with\nthe help of `{targets}` package). **Note: there are a few extra steps\nfor ‘Linux’ users, who don’t have any ‘Java’ previously installed in\ntheir system, and who prefer package installation from source, rather\nthen installing binaries from ‘Posit Package Manager’. See\n[documentation](https://www.ekotov.pro/rJavaEnv/articles/rJavaEnv.html#note-linux)\nfor details.**\n\n## Install\n\nInstall from CRAN:\n\n``` r\ninstall.packages('rJavaEnv')\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\n\nInstall the development version\n\u003c/summary\u003e\n\nInstall the latest release development version from **R-multiverse**:\n\n``` r\ninstall.packages('rJavaEnv',\n repos = c('https://community.r-multiverse.org', 'https://cloud.r-project.org')\n)\n```\n\nYou can also install the development version of `rJavaEnv` directly from\nGitHub:\n\n``` r\nif (!requireNamespace(\"remotes\", quietly = TRUE)) {\n  install.packages(\"remotes\")\n}\n\nremotes::install_github(\"e-kotov/rJavaEnv\", force = TRUE)\n```\n\n\u003c/details\u003e\n\n## Simple Example\n\n``` r\nrJavaEnv::java_quick_install(version = 21)\n```\n\nThis will:\n\n- download `Java` 21 distribution compatible with the current operating\n  system and processor architecture into a local cache folder;\n\n- extract the downloaded `Java` distribution into another cache folder;\n\n- create a symbolic link (for macOS and Linux) or junction (for Windows,\n  if that fails, just copies the files)\n  **rjavaenv/`platform`/`processor_architecture`/`java_version`** in the\n  current directory/project to point to the cached installation;\n\n- set the current session’s `JAVA_HOME` and `PATH` environment variables\n  to point to the installed (symlinked) `Java` distribution;\n\n- add code to `.Rprofile` file in the current directory/project to set\n  `JAVA_HOME` and `PATH` environment variables when the project is\n  opened in RStudio.\n\nAs part of normal operation, `rJavaEnv` will update the `JAVA_HOME` and\n`PATH` environment variables in the current R session, the local cache\nin your R package library, and the `.Rprofile` file in the\nproject/current working directory. In line with [CRAN\npolicies](https://cran.r-project.org/web/packages/policies.html),\nexplicit user consent is required before making these changes.\nTherefore, the first time you run any function from `rJavaEnv` that\nmakes such changes, you will be asked for consent. To explicitly consent\nand/or to prevent interruptions in non-interactive mode, you can use the\n`rje_consent()` function:\n\n``` r\nrje_consent(provided = TRUE)\n```\n\n## Using `rJavaEnv` with `targets` and `callr`\n\nJust insert this line into the begining of any script that you run with\n`targets` or `callr`:\n\n``` r\nrJavaEnv::use_java(\"21\")\n```\n\nThis acts exactly like `java_quick_install()`, but only sets the\nenvironment variables in the current session and does not copy or link\n`Java` binaries into the project directory.\n\nMore details are in the vignette [Multiple `Java` environments in one\nproject with `targets` and\n`callr`](https://www.ekotov.pro/rJavaEnv/articles/multiple-java-with-targets-callr.html).\n\n## Cleanup\n\nIf you do not want to use `rJavaEnv` anymore, please clear the cache\nfolders before removing the package:\n\n``` r\njava_clear(\"project\", delete_all = TRUE)\njava_clear(\"installed\", delete_all = TRUE)\njava_clear(\"distrib\", delete_all = TRUE)\n```\n\nAlso, clear the `.Rprofile` file in the projects there you used the\npackage:\n\n``` r\njava_env_unset()\n```\n\n## Functions Overview\n\nThe package has several core functions:\n\n1.  `java_quick_install()`\n    - Downloads, installs, and sets Java environment in the current\n      working/project directory, all in one line of code.\n2.  `java_check_version_cmd()`\n    - Checks the installed Java version using terminal commands. For\n      packages like\n      \u003ca href=\"https://github.com/ropensci/opentripplanner\"\n      target=\"_blank\"\u003e\u003ccode\u003eopentripplanner\u003c/code\u003e\u003c/a\u003e, that performs\n      Java calls using command line.\n3.  `java_version_check_rjava()`\n    - Checks the installed `Java` version using `rJava` in a separate R\n      session. For `rJava`-dependent packages such as\n      \u003ca href=\"https://github.com/ipeaGIT/r5r\"\n      target=\"_blank\"\u003e\u003ccode\u003er5r\u003c/code\u003e\u003c/a\u003e.\n4.  `java_download()`\n    - Downloads a specified version and distribution of `Java`.\n5.  `java_install()`\n    - Installs a `Java` distribution file into current (or\n      user-specified) project directory.\n6.  `java_env_set()`\n    - Sets the `JAVA_HOME` and `PATH` environment variables to a given\n      path in current R session and/or in the `.Rprofile` file in the\n      project directory.\n7.  `java_env_unset()`\n    - Remove the `JAVA_HOME` and `PATH` environment variables from the\n      `.Rrpofile` file in the project directory (but not in the current\n      R session, please restart the session so that R picks up the\n      system Java).\n8.  `java_list()`\n    - Lists all or some `Java` versions linked in the current project\n      (or cached distributions or installations).\n9.  `java_clear()`\n    - Removes all or some `Java` versions linked in the current project\n      (or cached distributions or installations).\n\n10 `java_valid_versions()` \\* Lists all valid major `Java` versions that\ncan be downloaded and installed for either current automatically\ndetected OS and CPU architecture or user-specified platform and\narchitecture.\n\n11. `use_java()`\n\n- Same as `java_quick_install()`, but in a less intrusive way. Does not\n  copy or link the `Java` installation folder from cache into the\n  project directory and does not create or edit your `.Rprofile` file.\n  Only sets requested java in the current R session.\n\nSee more details on all the functions in the\n\u003ca href=\"https://www.ekotov.pro/rJavaEnv/reference/index.html\"\ntarget=\"_blank\"\u003eReference\u003c/a\u003e.\n\nFor detailed usage, see the [Quick Start\nVignette](https://www.ekotov.pro/rJavaEnv/articles/rJavaEnv.html) (work\nin progress).\n\n## Limitations\n\nCurrently, `rJavaEnv` only supports major `Java` versions such as 8, 11,\n15 to 24 and any newer version. The download and install functions\nignore the minor version of the `Java` distribution and just downloads\nthe latest stable subversion of the specified major version. This is\ndone to simplify the process and avoid the need to update the package\nevery time a new minor version of `Java` is released. For most users\nthis should be sufficient, but this is substandard for full\nreproducibility.\n\nThe main limitation is that if you want to switch to another `Java`\nenvironment, you will most likely have to restart the current R session\nand set the `JAVA_HOME` and `PATH` environment variables to the desired\n`Java` environment using `rJavaEnv::java_env_set()`. This cannot be done\ndynamically within the same R session due to the way Java is initialized\nin R, particularly with the `rJava`-dependent packages such as\n\u003ca href=\"https://github.com/ipeaGIT/r5r\"\ntarget=\"_blank\"\u003e\u003ccode\u003er5r\u003c/code\u003e\u003c/a\u003e. With packages like\n\u003ca href=\"https://github.com/ropensci/opentripplanner\"\ntarget=\"_blank\"\u003e\u003ccode\u003eopentripplanner\u003c/code\u003e\u003c/a\u003e, that performs `Java`\ncalls using command line, you can switch `Java` environments dynamically\nwithin the same R session as much as you want.\n\nTherefore, if you need to use R packages that depend on different `Java`\nversions within the same project, you will have to create separate R\nscripts for each `Java` environment and run them in separate R sessions.\nOne effective way of doing this is to use the\n\u003ca href=\"https://github.com/r-lib/callr\"\ntarget=\"_blank\"\u003e\u003ccode\u003ecallr\u003c/code\u003e\u003c/a\u003e package to run R scripts in\nseparate R sessions. Another option is to use the\n\u003ca href=\"https://github.com/ropensci/targets\"\ntarget=\"_blank\"\u003e\u003ccode\u003etargets\u003c/code\u003e\u003c/a\u003e package to manage the whole\nproject workflow, which, as a side effect, will lead to all R scripts\nbeing run in separate R sessions. To use `rJavaEnv` with `targets`, you\nwill need to download and install several Java environments using\n`rJavaEnv::java_download()` and `rJavaEnv::java_install()` and set the\nrelevant path with `rJavaEnv::java_env_set()` at the beginning of each\nfunction that requires a certain `Java` version.\n\n## Future work\n\nThe future work includes:\n\n- Add support for more `Java` distributions and versions\n\n- Take care of \u003ca\n  href=\"https://solutions.posit.co/envs-pkgs/using-rjava/#reconfigure-r\"\n  target=\"_blank\"\u003e\u003ccode\u003eR CMD javareconf\u003c/code\u003e\u003c/a\u003e\n\n- Possibly add support for specifying `Java` version beyond the major\n  version\n\n- Possibly allow downloading several `Java` distributions in one\n  function call, e.g. different major versions of the same ‘flavour’ or\n  different ‘flavours’ of the same major version\n\n- Possibly add automation to get the `Java` that is required by specific\n  `Java`-dependent R packages\n\nI am open to suggestions and contributions, welcome to\n\u003ca href=\"https://github.com/e-kotov/rJavaEnv/issues\"\ntarget=\"_blank\"\u003eissues\u003c/a\u003e and\n\u003ca href=\"https://github.com/e-kotov/rJavaEnv/pulls\" target=\"_blank\"\u003epull\nrequests\u003c/a\u003e.\n\n## Acknowledgements\n\nI thank rOpenSci for the\n\u003ca href=\"https://devguide.ropensci.org/\" target=\"_blank\"\u003eDev Guide\u003c/a\u003e,\nas well as Hadley Wickham and Jennifer Bryan for the\n\u003ca href=\"https://r-pkgs.org/\" target=\"_blank\"\u003eR Packages\u003c/a\u003e book.\n\nPackage hex sticker logo is partially generated by DALL-E by OpenAI. The\nlogo also contains the original R logo.\n\n## Citation\n\nTo cite package ‘rJavaEnv’ in publications use:\n\nKotov E, Chan C (2024). *rJavaEnv: Java Environments for R Projects*.\ndoi:10.32614/CRAN.package.rJavaEnv\n\u003chttps://doi.org/10.32614/CRAN.package.rJavaEnv\u003e,\n\u003chttps://github.com/e-kotov/rJavaEnv\u003e.\n\nBibTeX:\n\n    @Manual{rjavaenv,\n      title = {rJavaEnv: Java Environments for R Projects},\n      author = {Egor Kotov and Chung-hong Chan},\n      year = {2024},\n      url = {https://github.com/e-kotov/rJavaEnv},\n      doi = {10.32614/CRAN.package.rJavaEnv},\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-kotov%2Frjavaenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-kotov%2Frjavaenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-kotov%2Frjavaenv/lists"}