Skip to content

Commit ce8868e

Browse files
authored
Merge pull request #84 from e-kotov/linux
Add Linux support for easy rJava loading, add env setting for building rJava from source an all platforms
2 parents c92d579 + 8593d06 commit ce8868e

27 files changed

+782
-59
lines changed

CITATION.cff

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,31 @@ message: 'To cite package "rJavaEnv" in publications use:'
88
type: software
99
license: MIT
1010
title: 'rJavaEnv: ''Java'' Environments for R Projects'
11-
version: 0.3.0
11+
version: 0.3.0.9000
1212
doi: 10.32614/CRAN.package.rJavaEnv
1313
identifiers:
1414
- type: doi
1515
value: 10.32614/CRAN.package.rJavaEnv
16-
abstract: 'Quickly install ''Java Development Kit (JDK)'' without administrative privileges
16+
abstract: Quickly install 'Java Development Kit (JDK)' without administrative privileges
1717
and set environment variables in current R session or project to solve common issues
18-
with ''Java'' environment management in ''R''. Recommended to users of ''Java''/''rJava''-dependent
19-
''R'' packages such as ''r5r'', ''opentripplanner'', ''xlsx'', ''openNLP'', ''rWeka'',
20-
''RJDBC'', ''tabulapdf'', and many more. ''rJavaEnv'' prevents common problems like
21-
''Java'' not found, ''Java'' version conflicts, missing ''Java'' installations,
22-
and the inability to install ''Java'' due to lack of administrative privileges.
23-
''rJavaEnv'' automates the download, installation, and setup of the ''Java'' on
24-
a per-project basis by setting the relevant ''JAVA_HOME'' in the current ''R'' session
25-
or the current working directory (via ''.Rprofile'', with the user''s consent).
26-
Similar to what ''renv'' does for ''R'' packages, ''rJavaEnv'' allows different
27-
''Java'' versions to be used across different projects, but can also be configured
28-
to allow multiple versions within the same project (e.g. with the help of ''targets''
29-
package). Note: there are a few extra steps for ''Linux'' users, who don''t have
30-
any ''Java'' previously installed in their system, and who prefer package installation
31-
from source, rather then installing binaries from ''Posit Package Manager''. See
32-
documentation for details.'
18+
with 'Java' environment management in 'R'. Recommended to users of 'Java'/'rJava'-dependent
19+
'R' packages such as 'r5r', 'opentripplanner', 'xlsx', 'openNLP', 'rWeka', 'RJDBC',
20+
'tabulapdf', and many more. 'rJavaEnv' prevents common problems like 'Java' not
21+
found, 'Java' version conflicts, missing 'Java' installations, and the inability
22+
to install 'Java' due to lack of administrative privileges. 'rJavaEnv' automates
23+
the download, installation, and setup of the 'Java' on a per-project basis by setting
24+
the relevant 'JAVA_HOME' in the current 'R' session or the current working directory
25+
(via '.Rprofile', with the user's consent). Similar to what 'renv' does for 'R'
26+
packages, 'rJavaEnv' allows different 'Java' versions to be used across different
27+
projects, but can also be configured to allow multiple versions within the same
28+
project (e.g. with the help of 'targets' package). For users who need to install
29+
'rJava' or other 'Java'-dependent packages from source, 'rJavaEnv' will display
30+
a message with instructions on how to run 'R CMD javareconf' to make the 'Java'
31+
configuration permanent, but also provides a function 'java_build_env_set' that
32+
sets the environment variables in the current R session temporarily to allow installation
33+
of 'rJava' from source without 'R CMD javareconf'. On 'Linux', in addition to setting
34+
environment variables, 'rJavaEnv' also dynamically loads 'libjvm.so' to ensure 'rJava'
35+
works correctly. See documentation for more details.
3336
authors:
3437
- family-names: Kotov
3538
given-names: Egor
@@ -131,6 +134,21 @@ references:
131134
orcid: https://orcid.org/0000-0002-4035-0289
132135
year: '2025'
133136
doi: 10.32614/CRAN.package.jsonlite
137+
- type: software
138+
title: rlang
139+
abstract: 'rlang: Functions for Base Types and Core R and ''Tidyverse'' Features'
140+
notes: Imports
141+
url: https://rlang.r-lib.org
142+
repository: https://CRAN.R-project.org/package=rlang
143+
authors:
144+
- family-names: Henry
145+
given-names: Lionel
146+
email: lionel@posit.co
147+
- family-names: Wickham
148+
given-names: Hadley
149+
email: hadley@posit.co
150+
year: '2025'
151+
doi: 10.32614/CRAN.package.rlang
134152
- type: software
135153
title: utils
136154
abstract: 'R: A Language and Environment for Statistical Computing'
@@ -183,4 +201,29 @@ references:
183201
year: '2025'
184202
doi: 10.32614/CRAN.package.testthat
185203
version: '>= 3.0.0'
204+
- type: software
205+
title: withr
206+
abstract: 'withr: Run Code ''With'' Temporarily Modified Global State'
207+
notes: Suggests
208+
url: https://withr.r-lib.org
209+
repository: https://CRAN.R-project.org/package=withr
210+
authors:
211+
- family-names: Hester
212+
given-names: Jim
213+
- family-names: Henry
214+
given-names: Lionel
215+
email: lionel@posit.co
216+
- family-names: Müller
217+
given-names: Kirill
218+
email: krlmlr+r@mailbox.org
219+
- family-names: Ushey
220+
given-names: Kevin
221+
email: kevinushey@gmail.com
222+
- family-names: Wickham
223+
given-names: Hadley
224+
email: hadley@posit.co
225+
- family-names: Chang
226+
given-names: Winston
227+
year: '2025'
228+
doi: 10.32614/CRAN.package.withr
186229

DESCRIPTION

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ Description: Quickly install 'Java Development Kit (JDK)' without
3030
Similar to what 'renv' does for 'R' packages, 'rJavaEnv' allows
3131
different 'Java' versions to be used across different projects, but
3232
can also be configured to allow multiple versions within the same
33-
project (e.g. with the help of 'targets' package). Note: there are a
34-
few extra steps for 'Linux' users, who don't have any 'Java'
35-
previously installed in their system, and who prefer package
36-
installation from source, rather then installing binaries from 'Posit
37-
Package Manager'. See documentation for details.
33+
project (e.g. with the help of 'targets' package). For users who need
34+
to install 'rJava' or other 'Java'-dependent packages from source,
35+
'rJavaEnv' will display a message with instructions on how to run 'R
36+
CMD javareconf' to make the 'Java' configuration permanent, but also
37+
provides a function 'java_build_env_set' that sets the environment
38+
variables in the current R session temporarily to allow installation
39+
of 'rJava' from source without 'R CMD javareconf'. On 'Linux', in
40+
addition to setting environment variables, 'rJavaEnv' also dynamically
41+
loads 'libjvm.so' to ensure 'rJava' works correctly. See
42+
documentation for more details.
3843
License: MIT + file LICENSE
3944
URL: https://github.com/e-kotov/rJavaEnv, https://www.ekotov.pro/rJavaEnv/
4045
BugReports: https://github.com/e-kotov/rJavaEnv/issues
@@ -45,6 +50,7 @@ Imports:
4550
cli,
4651
curl,
4752
jsonlite,
53+
rlang,
4854
utils
4955
Suggests:
5056
quarto,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(java_build_env_set)
4+
export(java_build_env_unset)
35
export(java_check_version_cmd)
46
export(java_check_version_rjava)
57
export(java_clear)
@@ -13,5 +15,6 @@ export(java_unpack)
1315
export(java_valid_versions)
1416
export(rje_consent)
1517
export(use_java)
18+
import(rlang)
1619
importFrom(utils,getFromNamespace)
1720
importFrom(utils,installed.packages)

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# rJavaEnv (development version)
22

3+
## New features
4+
5+
- Linux support. On Linux, `libjvm.so` location is automatically detected and force-loaded via `dyn.load()`. Thanks to that, `rJava` and any depenent R packages can be installed and loaded, if repositories with pre-built packages, such as `Posit Package Manager`, is used or if you build `rJava` from source, see the `java_build_env_set()` function.
6+
7+
- New function `java_build_env_set()` that sets the environment (either temporarily in the current session or in `./.Rprofile` file of the current working directory) to build `rJava` from source on `macOS`, `Linux` and `Windows` platforms. It uses the current value of `JAVA_HOME` environment variable by default, so that it is more convenient to use after `java_quick_install()` or `use_java()` commands. After running `java_build_env_set()`, users can install `rJava` from source with `install.packages("rJava", type = "source")` without any additional configuration. However, users will still need some system dependencies, e.g. on Linux they will need: libpcre2-dev, libdeflate-dev, libzstd-dev, liblzma-dev, libbz2-dev, zlib1g-dev, libicu-dev. A system message with a suggested `apt-get` command is printed. On Windows, `Rtools` must be installed. On `macOS`, `Xcode Command Line Tools` must be installed. See the new vignette `Install 'rJava' from source` for more details.
8+
9+
## Improvements
10+
11+
- `java_quick_install()` now also invisibly returns the path to `JAVA_HOME`.
12+
13+
- Added `{rlang}` as a dependency, as `{cli}` uses it anyway for the functions that we use in `{rJavaEnv}`, but does not declare it as a dependency. Therefore this previously might have caused annoyances to the users, as after installing `{rJavaEnv}` they could not use any of the functions until they installed `{rlang}` manually.
14+
315
# rJavaEnv 0.3.0
416

517
## New features

0 commit comments

Comments
 (0)