Example usage for java.lang System getenv

List of usage examples for java.lang System getenv

Introduction

In this page you can find the example usage for java.lang System getenv.

Prototype

public static String getenv(String name) 

Source Link

Document

Gets the value of the specified environment variable.

Usage

From source file:com.indeed.iupload.web.WebAppInitializer.java

protected boolean isDeveloperStationEnvironment() {
    final String env = System.getenv("SPRING_PROFILES_DEFAULT");
    return "developer".equals(env);
}

From source file:org.greencheek.utils.environment.propertyplaceholder.spring.TestEnvironmentalPropertySourcesPlaceholderConfigurerWithSpringValueResolution.java

@Test
public void testPropertyResolvedNoSystemProperties() {
    System.setProperty("ENVIRONMENT", "dev");
    System.setProperty("ENV", "dev");
    ctx = new ClassPathXmlApplicationContext(
            new String[] { "classpath:SpringValueResolution-NoSysProps-config.xml" });

    String value = (String) ctx.getBean("string");
    String valueSys = (String) ctx.getBean("string-sys");
    String valueEnv = (String) ctx.getBean("string-env");

    assertEquals("devproperties", value);

    assertEquals("${ENVIRONMENT}", valueSys);
    assertEquals(System.getenv("PATH"), valueEnv);
    ctx.close();/* w  w  w .  ja  va 2s.  c om*/

}