1 package org.kuali.common.util.execute.impl; 2 3 import java.nio.charset.Charset; 4 import java.util.Locale; 5 6 import org.apache.commons.lang3.StringUtils; 7 import org.kuali.common.util.execute.Executable; 8 import org.kuali.common.util.file.CanonicalFile; 9 import org.slf4j.Logger; 10 import org.slf4j.LoggerFactory; 11 12 public class ShowEnvExec implements Executable { 13 14 public ShowEnvExec() { 15 this(false); 16 } 17 18 public ShowEnvExec(boolean skip) { 19 this.skip = skip; 20 } 21 22 private static final Logger logger = LoggerFactory.getLogger(ShowEnvExec.class); 23 24 private final boolean skip; 25 26 @Override 27 public void execute() { 28 if (skip) { 29 return; 30 } 31 Object[] java = { System.getProperty("java.runtime.version"), System.getProperty("java.vm.name"), System.getProperty("java.vm.vendor") }; 32 Object[] javaHome = { new CanonicalFile(System.getProperty("java.home")) }; 33 Object[] JAVA_HOME = getJavaHomeEnvironmentVariable(); 34 Object[] other = { Locale.getDefault().toString(), Charset.defaultCharset().displayName() }; 35 Object[] os = { System.getProperty("os.name"), System.getProperty("os.version"), System.getProperty("os.arch") }; 36 logger.info("Java version: {}, name: {}, vendor: {}", java); 37 logger.info("Java home: {}", javaHome); 38 logger.info("JAVA_HOME: {}", JAVA_HOME); 39 logger.info("Default locale: {}, platform encoding: {}", other); 40 logger.info("OS name: {}, version: {}, arch: {}", os); 41 } 42 43 public Object[] getJavaHomeEnvironmentVariable() { 44 String javaHome = System.getenv("JAVA_HOME"); 45 if (StringUtils.isBlank(javaHome)) { 46 return new Object[] { "-- Not set --" }; 47 } else { 48 return new Object[] { new CanonicalFile(javaHome) }; 49 } 50 } 51 52 public boolean isSkip() { 53 return skip; 54 } 55 56 }