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:setiquest.renderer.Utils.java

/**
 * Constructor.//from   w w  w .j  ava2  s. co m
 */
public Utils() {
    Log.log("Properties file = " + System.getenv("PROJ_HOME") + "/properties/renderer.properties");
}

From source file:de.mpg.escidoc.services.extraction.ExtractionChain.java

public ExtractionChain() {
    this.pdftotext = System.getenv("extract.pdftotext.path");
    this.pdfboxAppJar = System.getenv("extract.pdfbox-app-jar.path");

    return;//from   ww  w .j a v  a 2  s .c om
}

From source file:com.verigreen.collector.jobs.HistoryCleanerJob.java

private void updateHistory(Map<String, List<JSONObject>> newHistory) {
    FileWriter file;/*from w ww.  j a v  a  2s. c o  m*/
    VerigreenNeededLogic.history = newHistory;
    try {
        file = new FileWriter(System.getenv("VG_HOME") + "//history.json");
        JSONObject history = new JSONObject(VerigreenNeededLogic.history);
        file.write(history.toString());
        file.flush();
        file.close();
    } catch (IOException e) {
        VerigreenLogger.get().error(getClass().getName(), RuntimeUtils.getCurrentMethodName(),
                String.format("Failed updating json file: " + System.getenv("VG_HOME") + "\\history.json", e));
    }
}

From source file:ch.ledcom.jpreseed.web.JPreseedController.java

@ModelAttribute("googleAnalytics")
public String googleAnalytics() {
    return System.getenv("GOOGLE_ANALYTICS");
}

From source file:com.seleniumtests.ut.browserfactory.mobile.TestLocalAppiumLauncher.java

/**
 * Test when appium home does not exist, an error is raised
 *//*from ww  w.  j  ava  2s . c  o m*/
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testAppiumNotFound() {
    PowerMockito.mockStatic(System.class);
    when(System.getenv("APPIUM_HOME")).thenReturn(null);
    new LocalAppiumLauncher();
}

From source file:com.googlecode.fascinator.common.FascinatorHome.java

/**
 * Gets an environment variable with default value if not set.
 * /*  w ww.  ja va  2s  .  c  o m*/
 * @param name environment variable name
 * @param def default value to return if environment variable not set
 * @return environment variable value
 */
private static String getenv(String name, String def) {
    String value = System.getenv(name);
    if (value == null) {
        return def;
    }
    return value;
}

From source file:io.sledge.core.impl.servlets.SledgeInstallServlet.java

@Override
protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    String envName = request.getParameter(SledgeConstants.ENVIRONMENT_NAME_PARAM);
    String overwriteEnvFileContent = request.getParameter(SledgeConstants.ENVIRONMENT_FILE_CONTENT_PARAM);

    if (StringUtils.isBlank(envName)) {
        envName = System.getenv(SledgeConstants.ENVIRONMENT_NAME_VARIABLE);
    }//  w  w  w  .  java 2  s  . co m

    java.util.Properties overwriteEnvProps = new java.util.Properties();
    if (overwriteEnvFileContent != null) {
        overwriteEnvProps.load(new StringReader(overwriteEnvFileContent));
    }

    Resource packageResource = request.getResource();
    ApplicationPackage appPackage = packageResource.adaptTo(ApplicationPackage.class);
    appPackage.setUsedEnvironment(envName);

    PackageRepository packageRepository = new SledgePackageRepository(request.getResourceResolver());

    try {
        Installer installer = new SledgeInstallerImpl(request);
        installer.install(appPackage, envName, overwriteEnvProps);

        appPackage.setState(ApplicationPackageState.INSTALLED.toString());
        packageRepository.updateApplicationPackage(appPackage);

    } catch (InstallationException e) {
        log.warn("Could not install Sledge package. ", e);
        appPackage.setState(ApplicationPackageState.FAILED.toString());
        packageRepository.updateApplicationPackage(appPackage);
    }

    String redirectUrl = request.getParameter(SlingPostConstants.RP_REDIRECT_TO);
    response.sendRedirect(redirectUrl);
}

From source file:com.opera.core.systems.util.ProfileUtils.java

public boolean isMainProfile(String prefsPath) {
    File prefsFile = new File(prefsPath);
    String absolutePrefsPath = prefsFile.getAbsolutePath();

    // Get user home
    String path = System.getProperty("user.home");

    if (isMac()) {
        /* Mac/*from  ww w .j a va2  s  .  c  o m*/
         * ~/Library/Application Support/Opera 
         * ~/Library/Caches/Opera 
         * ~/Library/Preferences/Opera Preferences
         */
        File appSupport = new File(path + "/Library/Application Support/Opera");
        File cache = new File(path + "/Library/Caches/Opera");
        File prefs = new File(path + "/Library/Preferences/Opera Preference");

        // Check if profiles start with this path
        if (absolutePrefsPath.startsWith(appSupport.getAbsolutePath())
                || absolutePrefsPath.startsWith(cache.getAbsolutePath())
                || absolutePrefsPath.startsWith(prefs.getAbsolutePath()))
            return true;

    } else if (isWindows()) {

        // On XP and Vista/7: 
        String appData = System.getenv("APPDATA");
        File appFile = new File(appData + "\\Opera");
        if (absolutePrefsPath.startsWith(appFile.getAbsolutePath()))
            return true;

        // On XP:
        String homeDrive = System.getenv("HOMEDRIVE");
        String homePath = System.getenv("HOMEPATH");
        File homeOpera = new File(homeDrive + homePath + "\\Local Settings\\Application Data\\Opera");
        if (absolutePrefsPath.startsWith(homeOpera.getAbsolutePath()))
            return true;

        // In Vista/7:
        String localAppData = System.getenv("LOCALAPPDATA");
        File localAppDataFile = new File(localAppData + "\\Opera");
        if (absolutePrefsPath.startsWith(localAppDataFile.getAbsolutePath()))
            return true;

        // On all Windows systems, <Installation Path>\profile:
        File exeFile = new File(settings.getOperaBinaryLocation());
        String parentPath = exeFile.getParent();
        File profileFolder = new File(parentPath + "\\profile");

        //a/b/c/exe
        //a/b/c/profile
        if (prefsFile.equals(profileFolder))
            return true;

    } else {

        /* *nix */
        File dotOpera = new File(path + "/.opera");
        if (/*platform nix && */ prefsFile.equals(dotOpera))
            return true;

    }

    return false;
}

From source file:com.tekstosense.opennlp.config.Config.java

/**
 * Instantiates a new config.//from   w  w w . j a  v a2s  . com
 */
private Config() {
    try {
        Parameters params = new Parameters();
        FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(
                PropertiesConfiguration.class);
        builder.configure(params.fileBased().setFileName("nlp.properties")
                .setLocationStrategy(new ClasspathLocationStrategy()));
        configuration = builder.getConfiguration();
        // Adding TEKSTO_HOME path to Configuration
        String homePath = System.getenv(TEKSTO_HOME);
        if (homePath != null && !homePath.isEmpty()) {
            configuration.setProperty(MODEL_PATH, homePath + "/Models");
        }
    } catch (ConfigurationException e) {
        LOG.error(e, e);
    }
}

From source file:com.codedx.burp.security.SSLConnectionSocketFactoryFactory.java

/**
 * Determines the location for the <code>truststore</code> file for the
 * given host. Each {@link SSLConnectionSocketFactory} returned by
 * {@link #initializeFactory(String)} needs to have a file to store
 * user-accepted invalid certificates; these files will be stored in the
 * user's OS-appropriate "appdata" directory.
 * /*from  w ww  .j  a  v  a2  s.  c  o  m*/
 * @param host A URL hostname, e.g. "www.google.com"
 * @return The file where the trust store for the given host should be
 *         stored
 */
private static File getTrustStoreForHost(String host) {
    String OS = System.getProperty("os.name").toUpperCase(Locale.getDefault());
    Path env;
    if (OS.contains("WIN")) {
        env = Paths.get(System.getenv("APPDATA"), "Code Dx", "Burp Extension");
    } else if (OS.contains("MAC")) {
        env = Paths.get(System.getProperty("user.home"), "Library", "Application Support", "Code Dx",
                "Burp Extension");
    } else if (OS.contains("NUX")) {
        env = Paths.get(System.getProperty("user.home"), ".codedx", "burp-extension");
    } else {
        env = Paths.get(System.getProperty("user.dir"), "codedx", "burp-extension");
    }

    File keystoreDir = new File(env.toFile(), ".usertrust");
    keystoreDir.mkdirs();

    // Host may only contain alphanumerics, dash, and dot.
    // Replace anything else with an underscore.
    String safeHost = host.replaceAll("[^a-zA-Z0-9\\-\\.]", "_");

    // <pluginstate>/.usertrust/<hostname>.truststore
    return new File(keystoreDir, safeHost + ".truststore");
}