List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:io.apiman.common.config.EnvLookup.java
/** * @see org.apache.commons.lang.text.StrLookup#lookup(java.lang.String) *//*from ww w. ja va 2 s .c om*/ @Override public String lookup(String key) { String value = System.getenv(key); if (value == null) { return ""; //$NON-NLS-1$ } else { return value; } }
From source file:eu.optimis.sm.gui.utils.ConfigManager.java
public static String getFilePath(String configFile) { String optimisHome = optimis_Home; if (optimisHome == null) { optimis_Home = System.getenv("OPTIMIS_HOME"); optimisHome = "/opt/optimis"; log.warn("Please set environment variable OPTIMIS_HOME. Using default /opt/optimis"); }/*from w w w . ja v a2 s .co m*/ File fileObject = new File(optimisHome.concat(configFile)); try { createDefaultConfigFile(fileObject); } catch (Exception ex) { log.error( "Error reading " + optimisHome.concat(configFile) + " configuration file: " + ex.getMessage()); log.error(ex.getMessage()); } return optimisHome.concat(configFile); }
From source file:com.citrixonline.android.utils.LocalAndroidSdk.java
public LocalAndroidSdk() { this(new File(System.getenv(ENV_ANDROID_HOME))); }
From source file:msearch.tool.MSFunktionen.java
public static int getOs() { int os = OS_UNKNOWN; if (System.getProperty("os.name").toLowerCase().contains("windows")) { if (System.getenv("ProgramFiles") != null) { // win 32Bit os = OS_WIN_32BIT;//from ww w . ja v a2 s. c om } else if (System.getenv("ProgramFiles(x86)") != null) { // win 64Bit os = OS_WIN_64BIT; } } else if (System.getProperty("os.name").toLowerCase().contains("linux")) { os = OS_LINUX; } else if (System.getProperty("os.name").toLowerCase().contains("mac")) { os = OS_MAC; } return os; }
From source file:io.kahu.hawaii.util.logger.Log4jConfigListener.java
@Override public void contextInitialized(ServletContextEvent sce) { String config = System.getenv("log4j.configuration"); if (StringUtils.isBlank(config)) { config = System.getProperty("log4j.configuration"); }//from www.j ava 2 s.c om if (StringUtils.isNotEmpty(config)) { String overrideConfig = StringUtils.replace(config, ".xml", ".local.xml"); if (!configureAndWatch(overrideConfig)) { configureAndWatch(config); sce.getServletContext().log("Configured to watch log configuration '" + config + "'"); } else { sce.getServletContext().log("Configured to watch log configuration '" + overrideConfig + "'"); } } }
From source file:ActivejdbcTest.java
@BeforeClass public static void setup() throws Exception { File webAppPath = new File("files"); micro = new Micro(webAppPath.getPath(), null, "../../lib"); Assert.assertNotNull(micro);/*from w ww . j av a 2 s .c o m*/ SITE = micro.getSite(); Assert.assertNotNull(SITE); SITE.setMicroEnv(Globals.TEST); // overwrite the ExtensionManager // todo: design a nicer support for integrating with the extensions testing units String extensionsFolder = System.getenv("EXTENSIONS_FOLDER"); Assert.assertNotNull("Must specify the extensions folder. Missing.", extensionsFolder); File extensionConfigFile = new File(extensionsFolder + EXTENSION_NAME + ".yml"); SITE.setExtensionsManager(new ExtensionsManager(SITE, new File[] { extensionConfigFile })); SITE.getExtensionsManager().require(EXTENSION_NAME); Assert.assertNotNull("Micro 'SITE' initialization failed", micro.getSite().getWebInfPath()); Assert.assertTrue("Micro is not pointing to the correct test web app", SITE.getWebInfPath().getAbsolutePath().contains("files/WEB-INF")); Assert.assertTrue("Micro test web app is not properly defined", SITE.getWebInfPath().exists()); }
From source file:edu.infsci2560.DatabaseConfig.java
@Bean public BasicDataSource dataSource() throws URISyntaxException { URI dbUri = new URI(System.getenv("DATABASE_URL")); String username = dbUri.getUserInfo().split(":")[0]; String password = dbUri.getUserInfo().split(":")[1]; String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' + dbUri.getPort() + dbUri.getPath() + "?sslmode=require"; BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(dbUrl);// ww w. j a v a 2 s .com basicDataSource.setUsername(username); basicDataSource.setPassword(password); return basicDataSource; }
From source file:com.reprezen.swaggerparser.test.ExamplesTest.java
@Parameters public static Collection<URL> findExamples() throws IOException { Collection<URL> examples = Lists.newArrayList(); Deque<URL> dirs = Queues.newArrayDeque(); String auth = System.getenv("GITHUB_AUTH") != null ? System.getenv("GITHUB_AUTH") + "@" : ""; String request = String.format("https://%sapi.github.com/repos/%s/contents/%s?ref=%s", auth, SPEC_REPO, EXAMPLES_ROOT, EXAMPLES_BRANCH); dirs.add(new URL(request)); while (!dirs.isEmpty()) { URL url = dirs.remove();/* w w w . j av a 2 s .co m*/ String json = IOUtils.toString(url, Charsets.UTF_8); JsonNode tree = mapper.readTree(json); for (JsonNode result : iterable(tree.elements())) { String type = result.get("type").asText(); String path = result.get("path").asText(); String resultUrl = result.get("url").asText(); if (type.equals("dir")) { dirs.add(new URL(resultUrl)); } else if (type.equals("file") && (path.endsWith(".yaml") || path.endsWith(".json"))) { String downloadUrl = result.get("download_url").asText(); examples.add(new URL(downloadUrl)); } } } return examples; }
From source file:com.centurylinkcloud.ecosystem.VcapVars.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String json = new String(); JSONObject jObj = null;/*from w w w . j a va 2 s .c o m*/ try { int spacesToIndentEachLevel = 2; json = new JSONObject(System.getenv("VCAP_SERVICES")).toString(spacesToIndentEachLevel); } catch (Exception e) { /* for local testing */ json = new String( "The environment variable 'VCAP_SERVICES' is not defined in your environment. <br>You have not yet added a service to be connected to."); } response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"j_example.css\""); out.println("</head>"); out.println("<body>"); out.println("<div align=\"center\">"); out.println("<h1>Your VCAP_Services environment variables are...</h1>"); out.println("</div>"); out.println("<div align=\"left\">"); out.println("<pre>"); out.println(json); out.println("</pre>"); out.println("<br>"); out.println("</div>"); out.println("</body>"); out.println("</html>"); } }
From source file:com.cloudera.sqoop.manager.NetezzaTestUtils.java
/** @return the current username. */ public static String getNZUser() { // First, check the $NZ_USER environment variable. String nzUser = System.getenv("NZ_USER"); if (nzUser == null) { // Else return what is in the NZ Properties nzUser = NZ_DB_USER;/* www . j ava2 s . c om*/ } return nzUser; }