javaVersion <- function(verbose = T, asNum = F){
# check system type
sysType <- .Platform$OS.type
# If windows:
if ( sysType == 'windows' ){
ret <- system( command = "java -version",
intern = T,
show.output.on.console = F )
# java version
jv = ret[ grep( pattern = "java version",
x = ret,
ignore.case = T) ]
jv.matches <- regmatches( x = jv,
m = gregexpr( pattern = "[[:digit:]]+",
text = jv ) )
jv.version <- as.numeric( x = unlist( x = jv.matches ) )
jv.version <- paste( jv.version[1], jv.version[2], sep = '.' )
# Write to console
if ( verbose ) cat( paste0( "Java version:\n", jv.version, '\n' ) )
# return
if ( asNum ){
return( as.numeric( jv.version ) )
}else{
return( jv.version )
}
}else{
stop( "Not currently set up for UNIX systems." )
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.