List of usage examples for java.lang System getenv
public static String getenv(String name)
From source file:net.orpiske.ssps.common.utils.Utils.java
private static String getUserHomeOrOverride() { String userHome = System.getenv("USER_LOCAL_DIRECTORY"); if (userHome == null) { userHome = FileUtils.getUserDirectoryPath(); }//from w w w .j a v a2s . co m return userHome + File.separator + USER_LOCAL_DIRECTORY; }
From source file:captor.app.CaptorOptionsParser.java
protected static String getDefaultInstallPath() { String[] installPathnames = new String[2]; File installPath = null;/*from w w w. ja v a2s.c om*/ installPathnames[0] = System.getenv("CAPTOR_HOME"); installPathnames[1] = System.getProperty("user.dir") + File.separator + ".."; for (String path : installPathnames) { if (path != null) { installPath = new File(path); if (installPath.exists() && installPath.isDirectory()) { break; } else { installPath = null; } } } try { return installPath.getCanonicalPath(); } catch (IOException e) { } return null; }
From source file:io.selendroid.android.JavaSdk.java
public static String javaHome() { if (javaHome == null) { // Sniff JAVA_HOME first javaHome = System.getenv("JAVA_HOME"); // If that's not present, and we're on a Mac... if (javaHome == null && Platform.getCurrent() == MAC) { try { javaHome = ShellCommand.exec(new CommandLine("/usr/libexec/java_home")); if (javaHome != null) { javaHome = javaHome.replaceAll("\\r|\\n", ""); }/*from w w w . j ava 2 s. co m*/ } catch (ShellCommandException e) { } } // Finally, check java.home, though this may point to a JRE. if (javaHome == null) { javaHome = System.getProperty("java.home"); } } return javaHome; }
From source file:Main.java
public static String getTitaniumSdkPath(String version) { final String homeFolder = System.getProperty("user.home"); String sdkPath = null;/*from w w w .ja va 2s .c om*/ File sdkFile = null; if (isMac()) { sdkPath = homeFolder + "/Library/Application Support/Titanium/mobilesdk/osx/" + version + "/"; sdkFile = new File(sdkPath); if (!sdkFile.exists()) { sdkPath = "/Library/Application Support/Titanium/mobilesdk/osx/" + version + "/"; sdkFile = new File(sdkPath); if (!sdkFile.exists()) { sdkPath = null; } } } else if (isWindows()) { final String userProfileFolder = System.getenv("ALLUSERSPROFILE"); sdkPath = userProfileFolder + "\\Titanium\\mobilesdk\\win32\\" + version + "\\"; sdkFile = new File(sdkPath); if (!sdkFile.exists()) { sdkPath = "C:\\Documents and Settings\\All Users\\Application Data\\Titanium\\mobilesdk\\win32\\" + version + "\\"; sdkFile = new File(sdkPath); if (!sdkFile.exists()) { sdkPath = null; } } } else if (isUnix()) { sdkPath = homeFolder + "/.titanium/mobilesdk/linux/" + version + "/"; sdkFile = new File(sdkPath); if (!sdkFile.exists()) { sdkPath = null; } } return sdkPath; }
From source file:com.github.trask.sandbox.saucelabs.SauceLabsCredentials.java
public static SauceLabsCredentials fromSystemEnv() { String username = System.getenv("SAUCE_LABS_USERNAME"); String apiKey = System.getenv("SAUCE_LABS_API_KEY"); if (StringUtils.isEmpty(username)) { throw new IllegalStateException("Missing environment variable SAUCE_LABS_USERNAME"); }//w w w .j ava 2s .co m if (StringUtils.isEmpty(apiKey)) { throw new IllegalStateException("Missing environment variable SAUCE_LABS_API_KEY"); } return new SauceLabsCredentials(username, apiKey); }
From source file:com.microsoft.alm.common.utils.SystemHelper.java
/** * This method is a wrapper for the System.getenv method which cannot be mocked. * * @param name// w ww. jav a 2 s. c om * @return */ public static String getEnvironmentVariable(final String name) { return System.getenv(name); }
From source file:com.thoughtworks.cruise.materials.TfsServer.java
private static String getPropertyOrBomb(String propertyName) { String username = System.getenv(propertyName); if (StringUtils.isBlank(username)) throw new RuntimeException(String.format("%s is not set", propertyName)); return username; }
From source file:dk.dma.commons.util.EnvironmentUtil.java
/** * Get the value of an OS environment variable. Issue a LOG error if the variable is blank or does not exist. * @param envVarName The name of the environment variable to lookup. * @return the value of the environment variable; or null if value not set. */// w ww . j a va 2 s.c o m public static String env(String envVarName) { String envVarValue = System.getenv(envVarName); if (isBlank(envVarValue)) { LOG.error("Environment variable \"" + envVarName + "\" not set."); envVarValue = null; } return envVarValue; }
From source file:fr.jetoile.hadoopunit.HadoopUtils.java
public static void setHadoopHome() { // Set hadoop.home.dir to point to the windows lib dir if (System.getProperty("os.name").startsWith("Windows")) { if (StringUtils.isEmpty(System.getenv("HADOOP_HOME"))) { try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { LOG.error("unable to load {}", HadoopUnitConfig.DEFAULT_PROPS_FILE, e); }//from w w w.j a va 2s. c om String hadoop_home = configuration.getString("HADOOP_HOME"); LOG.info("Setting hadoop.home.dir: {}", hadoop_home); if (hadoop_home == null) { LOG.error("HADOOP_HOME should be set or informed into hadoop-unit-default.properties"); System.exit(-1); } else { System.setProperty("HADOOP_HOME", hadoop_home); } } else { System.setProperty("HADOOP_HOME", System.getenv("HADOOP_HOME")); } String windowsLibDir = System.getenv("HADOOP_HOME"); LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir); System.setProperty("hadoop.home.dir", windowsLibDir); System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll") .getAbsolutePath()); System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll") .getAbsolutePath()); } }
From source file:com.ansorgit.plugins.bash.util.SystemPathUtil.java
@Nullable public static String findBestExecutable(@NotNull String commandName) { List<String> paths = Arrays.asList(StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar)); return findBestExecutable(commandName, paths); }