Search code examples
javarinstallationpackagerjava

Discover all installed R packages with a Java dependency (for security reasons)


For security reasons I am forced to de-install Java (JRE) on a machine I am using with R.

How can I (easily :-) discover all installed packages that use Java?

Edit 14.12.2021: The log4j-log4shell-cve-2021-44228-vulnerability makes this question (and answers) even more interesting ;-)


Solution

  • You can use installed.packages to determine which packages import the rJava package. You need to tell installed.packages to include the Imports field from the package description, and then check which packages import rJava.

    LIBS = installed.packages(fields=c("Imports"))
    JPacks = grep("Java", LIBS[,"Imports"], ignore.case=TRUE)
    LIBS[JPacks, c("Package", "Imports")]
              Package    
    RWeka     "RWeka"    
    RWekajars "RWekajars"
              Imports                                                                
    RWeka     "RWekajars (>= 3.9.0), rJava (>= 0.6-3), graphics, stats,\nutils, grid"
    RWekajars "rJava (>= 0.6-3)"