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 java.util.Map<String, String> getenv() 

Source Link

Document

Returns an unmodifiable string map view of the current system environment.

Usage

From source file:com.azaptree.services.spring.application.SpringApplicationService.java

private static void logEnvironment(final Logger log) {
    if (log.isDebugEnabled()) {
        final TreeMap<String, String> sysProps = new TreeMap<>(System.getenv());
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final PrintStream ps = new PrintStream(bos);
        for (final Map.Entry<String, String> entry : sysProps.entrySet()) {
            ps.print(entry.getKey());//from   w ww  . j  a  v  a 2  s  .  c om
            ps.print('=');
            ps.println(entry.getValue());
        }
        log.debug("Environment:\n{}", bos);
    }
}

From source file:com.blackducksoftware.integration.hub.detect.util.executable.Executable.java

public ProcessBuilder createProcessBuilder() {
    final List<String> processBuilderArguments = createProcessBuilderArguments();
    final ProcessBuilder processBuilder = new ProcessBuilder(processBuilderArguments);
    processBuilder.directory(workingDirectory);
    final Map<String, String> processBuilderEnvironment = processBuilder.environment();
    final Map<String, String> systemEnv = System.getenv();
    for (final String key : systemEnv.keySet()) {
        populateEnvironmentMap(processBuilderEnvironment, key, systemEnv.get(key));
    }/*from   w  w w  .j  a va2  s . c  om*/
    for (final String key : environmentVariables.keySet()) {
        populateEnvironmentMap(processBuilderEnvironment, key, environmentVariables.get(key));
    }
    return processBuilder;
}

From source file:com.ery.estorm.util.ServerCommandLine.java

/**
 * Logs information about the currently running JVM process including the environment variables. Logging of env vars can be disabled by
 * setting {@code "hbase.envvars.logging.disabled"} to {@code "true"}.
 * <p>//from ww  w .  jav  a 2  s .  co  m
 * If enabled, you can also exclude environment variables containing certain substrings by setting
 * {@code "hbase.envvars.logging.skipwords"} to comma separated list of such substrings.
 */
public static void logProcessInfo(Configuration conf) {
    // log environment variables unless asked not to
    if (conf == null || !conf.getBoolean("estorm.envvars.logging.disabled", false)) {
        Set<String> skipWords = new HashSet<String>(DEFAULT_SKIP_WORDS);
        if (conf != null) {
            String[] confSkipWords = conf.getStrings("hbase.envvars.logging.skipwords");
            if (confSkipWords != null) {
                skipWords.addAll(Arrays.asList(confSkipWords));
            }
        }

        nextEnv: for (Entry<String, String> entry : System.getenv().entrySet()) {
            String key = entry.getKey().toLowerCase();
            String value = entry.getValue().toLowerCase();
            // exclude variables which may contain skip words
            for (String skipWord : skipWords) {
                if (key.contains(skipWord) || value.contains(skipWord))
                    continue nextEnv;
            }
            LOG.info("env:" + entry);
        }
    }
    // and JVM info
    logJVMInfo();
}

From source file:utils.TestUtils.java

public static void initWiltonOnce(WiltonGateway gateway, String loggingConf) {
    if (INITTED.compareAndSet(false, true)) {
        String pathToWiltonDir = getJsDir().getAbsolutePath();
        String jsPath = "file://" + new File(pathToWiltonDir, "js").getAbsolutePath() + File.separator;
        String appdir = pathToWiltonDir + "/core/test/";
        ArrayList<LinkedHashMap<String, String>> packagesList = loadPackagesList(pathToWiltonDir);
        String config = GSON.toJson(ImmutableMap.builder().put("defaultScriptEngine", "javatest")
                .put("applicationDirectory", appdir).put("environmentVariables", System.getenv())
                .put("requireJs", ImmutableMap.builder().put("waitSeconds", 0).put("enforceDefine", true)
                        .put("nodeIdCompat", true).put("baseUrl", jsPath)
                        .put("paths", ImmutableMap.builder()
                                .put("test/scripts", jsPath + "../core/test/scripts").build())
                        .put("packages", packagesList).build())
                .build());//from   w ww .  ja v  a  2 s. c o m

        WiltonJni.initialize(config);
        WiltonJni.registerScriptGateway(gateway, "javatest");
        GATEWAY = gateway;
        String libdir = appdir + "../../build/bin";
        // logging init
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_logging").put("directory", libdir).build()));
        wiltoncall("logging_initialize", loggingConf);
        // libs load
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_service").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_crypto").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library",
                GSON.toJson(ImmutableMap.builder().put("name", "wilton_zip").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_loader").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_channel").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_cron").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library",
                GSON.toJson(ImmutableMap.builder().put("name", "wilton_db").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library",
                GSON.toJson(ImmutableMap.builder().put("name", "wilton_fs").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_http").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON.toJson(
                ImmutableMap.builder().put("name", "wilton_mustache").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library",
                GSON.toJson(ImmutableMap.builder().put("name", "wilton_net").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library",
                GSON.toJson(ImmutableMap.builder().put("name", "wilton_pdf").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_process").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_server").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_signal").put("directory", libdir).build()));
        wiltoncall("dyload_shared_library", GSON
                .toJson(ImmutableMap.builder().put("name", "wilton_thread").put("directory", libdir).build()));
    }
}

From source file:com.qwazr.server.configuration.ServerConfiguration.java

public ServerConfiguration(final String... args) throws IOException {
    this(System.getenv(), System.getProperties(), argsToMap(args));
}

From source file:com.garyclayburg.BootVaadin.java

public static void dumpSystemProperties() {
    log.info("system properties dump");
    Properties systemProperties = System.getProperties();
    TreeMap tm = new TreeMap(systemProperties);
    for (Object o : tm.keySet()) {
        String key = (String) o;
        log.info(key + ": " + tm.get(o));
    }/* w  ww  .ja va2  s  .c  om*/
    Map<String, String> getenv = new TreeMap<>(System.getenv());
    log.info("system environment dump");
    for (String key : getenv.keySet()) {
        log.info("env " + key + ": " + getenv.get(key));
    }
}