List of usage examples for java.lang System getenv
public static java.util.Map<String, String> getenv()
From source file:Main.java
public static Process runWithEnv(String command, ArrayList<String> customAddedEnv, String baseDirectory) throws IOException { Map<String, String> environment = System.getenv(); String[] envArray = new String[environment.size() + (customAddedEnv != null ? customAddedEnv.size() : 0)]; int i = 0;/*from w ww . j a v a2 s . c o m*/ for (Map.Entry<String, String> entry : environment.entrySet()) { envArray[i++] = entry.getKey() + "=" + entry.getValue(); } if (customAddedEnv != null) { for (String entry : customAddedEnv) { envArray[i++] = entry; } } Process process; if (baseDirectory == null) { process = Runtime.getRuntime().exec(command, envArray, null); } else { process = Runtime.getRuntime().exec(command, envArray, new File(baseDirectory)); } return process; }
From source file:nebula.plugin.metrics.model.Info.java
public static Info create(Tool tool, Tool scm, Tool ci) { return create(tool, scm, ci, System.getenv(), new HashMap(System.getProperties())); }
From source file:Connector.Connector.java
private void setCredentials() { Map<String, String> env = System.getenv(); if (env.containsKey("VCAP_SERVICES")) { try {/*from w w w .j ava 2s . com*/ JSONParser parser = new JSONParser(); JSONObject vcap = (JSONObject) parser.parse(env.get("VCAP_SERVICES")); JSONObject service = null; for (Object key : vcap.keySet()) { String keyStr = (String) key; if (keyStr.toLowerCase().contains("tradeoff_analytics")) { service = (JSONObject) ((JSONArray) vcap.get(keyStr)).get(0); break; } } if (service != null) { JSONObject creds = (JSONObject) service.get("credentials"); String username = (String) creds.get("username"); String password = (String) creds.get("password"); this.username = username; this.password = password; System.out.println(username); System.out.println(password); } } catch (Exception e) { e.printStackTrace(System.err); } } }
From source file:com.enonic.cms.core.boot.HomeResolver.java
public HomeResolver() { setSystemProperties(System.getProperties()); setEnvironment(System.getenv()); setDefaultHome(new File(SystemUtils.getUserHome(), "cms-home")); }
From source file:com.sixt.service.framework.servicetest.helper.DockerComposeHelper.java
/** * Set environment variable "kafkaServer" to the host and port specified by * docker//from w w w .j a v a 2 s. com */ public static void setKafkaEnvironment(DockerComposeRule docker) { DockerPort kafka = docker.containers().container("kafka").port(9092); Map<String, String> newEnv = new HashMap<>(); newEnv.put(ServiceProperties.KAFKA_SERVER_KEY, kafka.inFormat("$HOST:$EXTERNAL_PORT")); newEnv.putAll(System.getenv()); setEnv(newEnv); }
From source file:Main.java
/** * Prepares the theme. The theme can be overridden with the specified environment variable. The default is the * system look and feel./*from w w w . ja v a2s .c o m*/ * * @param overrideEnvVar * The environment variable to check for override value. Specify null for don't use override variable * @throws Exception * When setting the theme failed */ public static void prepareTheme(final String overrideEnvVar) throws Exception { final String sysThemeStr = overrideEnvVar == null ? null : System.getenv().get(overrideEnvVar); System.setProperty("apple.laf.useScreenMenuBar", "true"); if (sysThemeStr == null || Boolean.parseBoolean(sysThemeStr)) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } }
From source file:test.com.azaptree.services.spring.application.config.WebApplicationSpringConfig.java
@Bean public Map<String, String> env() { return System.getenv(); }
From source file:com.gopivotal.cloudfoundry.test.core.InitializationUtils.java
/** * Create a new instance of the utility */ public InitializationUtils() { this(System.getenv()); }
From source file:com.opensymphony.xwork2.config.providers.EnvsValueSubstitutor.java
public EnvsValueSubstitutor() { strSubstitutor = new StrSubstitutor(System.getenv()); strSubstitutor.setVariablePrefix("${env."); strSubstitutor.setVariableSuffix('}'); strSubstitutor.setValueDelimiter(":"); }
From source file:com.netflix.spinnaker.clouddriver.jobs.JobRequest.java
public JobRequest(List<String> tokenizedCommand) { this(tokenizedCommand, System.getenv(), new ByteArrayInputStream(new byte[0])); }