[R] Identifying presence of Java

Dennis Fisher ||@her @end|ng |rom p|e@@th@n@com
Sat Nov 9 17:51:43 CET 2019

R 3.6.3
OSX and Windows


I want to identify if Java is installed on a particular computer.

When I execute
	Java -version
in a terminal (OSX), but not in R, there are two outcomes:
Java installed yields:
	java version "13.0.1" 2019-10-15 
	Java(TM) SE Runtime Environment (build 13.0.1+9) 
	Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing) 

Java not installed yields:
	No Java runtime installed

I assume that there are comparable outputs in Windows.

I would like to capture this output in R using the system command, then search for “No Java runtime installed” )or the correponding text in Windows).

I execute something like:
	CAPTURE	<- system("Java -version", intern=TRUE, ignore.stderr=FALSE, ignore.stdout=FALSE)	
(with various permutations of TRUE/FALSE for the options) but I cannot capture what is displayed on the console.

I have also tried “system2” with various TRUE/FALSE permutations without success.

Any clever ideas?


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)

More information about the R-help mailing list