Example usage for java.io File pathSeparator

List of usage examples for java.io File pathSeparator

Introduction

In this page you can find the example usage for java.io File pathSeparator.

Prototype

String pathSeparator

To view the source code for java.io File pathSeparator.

Click Source Link

Document

The system-dependent path-separator character, represented as a string for convenience.

Usage

From source file:jeplus.RadianceWinTools.java

/**
 * Call Rtrace to run the simulation//from w w  w. j  a v  a 2 s  .  c  o  m
 * @param config Radiance Configuration
 * @param WorkDir The working directory where the input files are stored and the output files to be generated
 * @param args
 * @param model
 * @param in
 * @param out
 * @param err
 * @param process
 * @return the result code represents the state of execution steps. >=0 means successful
 */
public static int runRtrace(RadianceConfig config, String WorkDir, String args, String model, String in,
        String out, String err, ProcessWrapper process) {

    int ExitValue = -99;

    try {
        StringBuilder buf = new StringBuilder(config.getResolvedRadianceBinDir());
        buf.append(File.separator).append("rtrace");

        List<String> command = new ArrayList<>();
        command.add(buf.toString());
        String[] arglist = args.split("\\s+");
        command.addAll(Arrays.asList(arglist));
        command.add(model);
        ProcessBuilder builder = new ProcessBuilder(command);
        builder.directory(new File(WorkDir));
        builder.environment().put("RAYPATH", "." + File.pathSeparator + config.getResolvedRadianceLibDir());
        builder.redirectError(new File(WorkDir + File.separator + err));
        builder.redirectOutput(new File(WorkDir + File.separator + out));
        builder.redirectInput(new File(WorkDir + File.separator + in));

        Process proc = builder.start();
        if (process != null) {
            process.setWrappedProc(proc);
        }
        ExitValue = proc.waitFor();
    } catch (IOException | InterruptedException ex) {
        logger.error("Error occoured when executing Rtrace", ex);
    }

    // Return Radiance exit value
    return ExitValue;
}

From source file:dk.netarkivet.common.utils.ApplicationUtils.java

/**
 * Starts up an LifeCycleComponent. // ww w . j  av  a2s  .c om
 * 
 * @param component The component to start.
 */
public static void startApp(LifeCycleComponent component) {
    ArgumentNotValid.checkNotNull(component, "LifeCycleComponent component");

    String appName = component.getClass().getName();
    Settings.set(CommonSettings.APPLICATION_NAME, appName);
    logAndPrint("Starting " + appName + "\n" + Constants.getVersionString());
    log.info("Using settings files '" + StringUtils.conjoin(File.pathSeparator, Settings.getSettingsFiles())
            + "'");
    dirMustExist(FileUtils.getTempDir());
    // Start the remote management connector
    try {
        MBeanConnectorCreator.exposeJMXMBeanServer();
        log.trace("Added remote management for " + appName);
    } catch (Throwable e) {
        logExceptionAndPrint("Could not add remote management for class " + appName, e);
        System.exit(EXCEPTION_WHEN_ADDING_MANAGEMENT);
    }

    component.start();
    logAndPrint(appName + " Running");

    // Add the shutdown hook
    try {
        log.trace("Adding shutdown hook for " + appName);
        Runtime.getRuntime().addShutdownHook((new ShutdownHook(component)));
        log.trace("Added shutdown hook for " + appName);
    } catch (Throwable e) {
        logExceptionAndPrint("Could not add shutdown hook for class " + appName, e);
        System.exit(EXCEPTION_WHEN_ADDING_SHUTDOWN_HOOK);
    }
}

From source file:org.hyperic.hq.plugin.jboss.JBossDetector.java

private static void findServerProcess(List<JBossInstance> servers, String query) {
    bindings.clear();//from w  w  w .j a  v  a2s . co  m

    long[] pids = getPids(query);

    for (int i = 0; i < pids.length; i++) {
        String[] args = getProcArgs(pids[i]);

        String classpath = null;
        String runJar = null;
        String config = "default";
        String address = null;
        String srvHomeUrl = null;
        String srvConfigUrl = null;
        String srvBaseUrl = null;
        String configPath = null;
        String installPath = null;
        boolean mainArgs = false;

        for (int j = 0; j < args.length; j++) {
            String arg = args[j];

            if (arg.equals("-classpath") || arg.equals("-cp")) {
                classpath = args[j + 1];
                continue;
            } else if (arg.startsWith(PROP_CP)) {
                classpath = arg.substring(PROP_CP.length());
                continue;
            } else if (arg.startsWith(PROP_AGENT)) {
                //.../bin/pluggable-instrumentor.jar
                runJar = arg.substring(PROP_AGENT.length());
                continue;
            } else if (arg.startsWith(PROP_SRV_CONFIG_URL)) {
                srvConfigUrl = arg.substring(PROP_SRV_CONFIG_URL.length());
                continue;
            } else if (arg.startsWith(PROP_SRV_HOME_URL)) {
                srvHomeUrl = arg.substring(PROP_SRV_HOME_URL.length());
                continue;
            } else if (arg.startsWith(PROP_SRV_BASE_URL)) {
                srvBaseUrl = arg.substring(PROP_SRV_BASE_URL.length());
                continue;
            }

            if (!mainArgs && arg.equals(JBOSS_MAIN)) {
                mainArgs = true;
                continue;
            }

            //run.sh -c serverName
            if (mainArgs && arg.startsWith("-c")) {
                config = arg.substring(2, arg.length());
                if (config.equals("")) {
                    config = args[j + 1];
                }
                continue;
            } else if (mainArgs && arg.startsWith("-b")) {
                address = arg.substring(2, arg.length());
                if (address.equals("")) {
                    address = args[j + 1];
                }
                continue;
            }
        }

        File configDir = null;
        if (srvConfigUrl != null) {
            configDir = getFileFromURL(srvConfigUrl);
            if (configDir != null) {
                configDir = configDir.getParentFile();
            }
        } else if (srvHomeUrl != null) {
            configDir = getFileFromURL(srvHomeUrl);
        } else if ((srvBaseUrl != null) && (config != null)) {
            configDir = getFileFromURL(srvBaseUrl);
            if (configDir != null) {
                configDir = new File(configDir, config);
            }
        }

        if ((configDir != null) && configDir.exists()) {
            configPath = configDir.getAbsolutePath();
        }

        if (classpath != null) {
            StringTokenizer tok = new StringTokenizer(classpath, File.pathSeparator);

            while (tok.hasMoreTokens()) {
                String jar = tok.nextToken();
                if (jar.endsWith("run.jar")) {
                    runJar = jar;
                    break;
                }
            }
        }

        if (runJar == null) {
            continue;
        }

        //e.g. runJar == /usr/local/jboss-4.0.2/bin/run.jar
        File root = new File(runJar).getParentFile();
        if ((root == null) || root.getPath().equals(".")) {
            String cwd = getProcCwd(pids[i]);
            if (cwd == null) {
                continue;
            } else {
                root = new File(cwd);
            }
        }

        root = root.getParentFile();
        if (root == null) {
            continue;
        }

        if (configPath == null) {
            configPath = getServerConfigPath(root, config);
        }

        if (address != null) {
            bindings.put(configPath, address);
        }

        installPath = root.getAbsolutePath();

        servers.add(new JBossInstance(installPath, configPath, pids[i]));
    }
}

From source file:com.synopsys.arc.jenkinsci.plugins.cygwinprocesskiller.util.CygwinKillHelper.java

private Map<String, String> constructVariables() throws IOException, InterruptedException {
    Map<String, String> envVars = new TreeMap<String, String>();
    if (tool != null) {
        FilePath homePath = getSubstitutedHome();
        String overridenPaths = homePath.child("bin").getRemote() + File.pathSeparator
                + homePath.child("lib").getRemote();
        envVars.put("PATH", overridenPaths);
        envVars.put("CYGWIN_HOME", homePath.getRemote());
    }//w w  w  .  ja va  2  s. co m
    return envVars;
}

From source file:org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl.java

private String getClasspath() {
    StringBuilder classpathBuilder = new StringBuilder();
    classpathBuilder.append(config.getConfDir().getAbsolutePath());

    if (config.getHadoopConfDir() != null)
        classpathBuilder.append(File.pathSeparator).append(config.getHadoopConfDir().getAbsolutePath());

    if (config.getClasspathItems() == null) {
        String javaClassPath = System.getProperty("java.class.path");
        if (javaClassPath == null) {
            throw new IllegalStateException("java.class.path is not set");
        }//w  ww. ja va 2s  .  c o  m
        classpathBuilder.append(File.pathSeparator).append(javaClassPath);
    } else {
        for (String s : config.getClasspathItems())
            classpathBuilder.append(File.pathSeparator).append(s);
    }

    return classpathBuilder.toString();
}

From source file:it.tidalwave.northernwind.core.impl.model.DefaultSiteProvider.java

/*******************************************************************************************************************
 *
 *
 *
 ******************************************************************************************************************/
@PostConstruct//from   w  ww  . ja va2  s. c o m
/* package */ void initialize() {
    log.info("initialize()");
    ignoredFolders.addAll(Arrays.asList(ignoredFoldersAsString.trim().split(File.pathSeparator)));

    for (final String localeAsString : localesAsString.split(",")) {
        configuredLocales.add(new Locale(localeAsString.trim()));
    }

    reload();
}

From source file:de.xirp.plugin.PluginLoader.java

/**
 * Checks the needs of all plugins./*w w w .j av a2  s. co m*/
 * 
 * @see IPlugable#requiredLibs()
 */
@SuppressWarnings("unchecked")
private static void checkAllNeeds() {
    HashMap<String, IPlugable> plugables = new HashMap<String, IPlugable>();
    MultiValueHashMap<String, String> refs = new MultiValueHashMap<String, String>();

    // list of all plugins
    List<String> fullPluginList = new ArrayList<String>(plugins.size());
    for (PluginInfo info : plugins.values()) {
        fullPluginList.add(info.getMainClass());
    }

    ClassLoader loader = logClass.getClass().getClassLoader();

    // Read the list of available jars from the class path
    String cp = ManagementFactory.getRuntimeMXBean().getClassPath();
    // String cp = System.getProperty("java.class.path");
    // //$NON-NLS-1$
    String[] jars = cp.split(File.pathSeparator);
    List<String> jarList = new ArrayList<String>(jars.length);
    for (String jar : jars) {
        jarList.add(FilenameUtils.getName(jar));
    }
    // The initial list of current plugins equals the full list
    // every plugin which does not full fill the needs
    // it removed from this list
    currentPluginList = new ArrayList<String>(fullPluginList);
    for (PluginInfo info : plugins.values()) {
        try {
            SecurePluginView view = PluginManager.getInstance(info, Robot.NAME_NONE);
            plugables.put(info.getMainClass(), view);
            boolean check = checkNeeds(view, loader, jarList);
            if (!check) {
                // remove plugins which reference this plugin
                removeRefs(info.getMainClass());
            }
        } catch (Exception e) {
            logClass.trace(e, e);
        }
    }
    // Remove all plugins of the full list
    // which are no more contained in the current list
    for (String clazz : fullPluginList) {
        if (!currentPluginList.contains(clazz)) {
            plugins.remove(clazz);
            plugables.remove(clazz);
        }
    }
    instances = new ArrayList<IPlugable>(plugables.values());
    refs.clear();
    refs = null;
    currentPluginList.clear();
    currentPluginList = null;
    fullPluginList.clear();
    fullPluginList = null;
}

From source file:org.apache.geode.test.dunit.standalone.ProcessManager.java

private String[] buildJavaCommand(int vmNum, int namingPort, String version) {
    String cmd = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
    String dunitClasspath = System.getProperty("java.class.path");
    String classPath;//www.j  a  va  2s . c om
    if (!VersionManager.isCurrentVersion(version)) {
        classPath = versionManager.getClasspath(version) + File.pathSeparator + dunitClasspath;
    } else {
        classPath = dunitClasspath;
    }

    // String tmpDir = System.getProperty("java.io.tmpdir");
    String agent = getAgentString();

    String jdkDebug = "";
    if (debugPort > 0) {
        jdkDebug += ",address=" + debugPort;
        debugPort++;
    }

    String jdkSuspend = vmNum == suspendVM ? "y" : "n"; // ignore version
    ArrayList<String> cmds = new ArrayList<String>();
    cmds.add(cmd);
    cmds.add("-classpath");
    classPath = removeJREJars(classPath);
    cmds.add(classPath);
    cmds.add("-D" + DUnitLauncher.RMI_PORT_PARAM + "=" + namingPort);
    cmds.add("-D" + DUnitLauncher.VM_NUM_PARAM + "=" + vmNum);
    cmds.add("-D" + DUnitLauncher.VM_VERSION_PARAM + "=" + version);
    cmds.add("-D" + DUnitLauncher.WORKSPACE_DIR_PARAM + "=" + new File(".").getAbsolutePath());
    if (vmNum >= 0) { // let the locator print a banner
        if (version.equals(VersionManager.CURRENT_VERSION)) { // enable the banner for older versions
            cmds.add("-D" + InternalLocator.INHIBIT_DM_BANNER + "=true");
        }
    } else {
        // most distributed unit tests were written under the assumption that network partition
        // detection is disabled, so we turn it off in the locator. Tests for network partition
        // detection should create a separate locator that has it enabled
        cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX + ENABLE_NETWORK_PARTITION_DETECTION + "=false");
    }
    cmds.add("-D" + LOG_LEVEL + "=" + DUnitLauncher.logLevel);
    if (DUnitLauncher.LOG4J != null) {
        cmds.add("-Dlog4j.configurationFile=" + DUnitLauncher.LOG4J);
    }
    cmds.add("-Djava.library.path=" + System.getProperty("java.library.path"));
    cmds.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=" + jdkSuspend + jdkDebug);
    cmds.add("-XX:+HeapDumpOnOutOfMemoryError");
    cmds.add("-Xmx512m");
    cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX + "DEFAULT_MAX_OPLOG_SIZE=10");
    cmds.add("-D" + DistributionConfig.GEMFIRE_PREFIX + "disallowMcastDefaults=true");
    cmds.add("-D" + DistributionConfig.RESTRICT_MEMBERSHIP_PORT_RANGE + "=true");
    cmds.add("-ea");
    cmds.add("-XX:MetaspaceSize=512m");
    cmds.add("-XX:+PrintGC");
    cmds.add("-XX:+PrintGCDetails");
    cmds.add("-XX:+PrintGCTimeStamps");
    cmds.add(agent);
    cmds.add(ChildVM.class.getName());
    String[] rst = new String[cmds.size()];
    cmds.toArray(rst);

    return rst;
}

From source file:org.jbpm.bpel.tools.WscompileTool.java

private static String formatClasspath() {
    // include the jax-rpc and saaj classes in the classpath
    String jaxrpcLocation = getLocation(Service.class);
    String saajLocation = getLocation(SOAPMessage.class);
    String classpath = jaxrpcLocation != null
            ? (saajLocation != null ? jaxrpcLocation + File.pathSeparator + saajLocation : jaxrpcLocation)
            : (saajLocation != null ? saajLocation : "");
    log.debug("using classpath: " + classpath);
    return classpath;
}

From source file:org.apache.james.repository.file.AbstractFileRepository.java

@Override
public Repository getChildRepository(String childName) {
    AbstractFileRepository child;/*from w ww  .j  av a2  s.co m*/

    try {
        child = createChildRepository();
    } catch (Exception e) {
        throw new RuntimeException("Cannot create child repository " + childName + " : " + e);
    }

    child.setFileSystem(fileSystem);
    child.setLog(logger);

    try {
        child.setDestination(
                m_baseDirectory.getAbsolutePath() + File.pathSeparatorChar + childName + File.pathSeparator);
    } catch (ConfigurationException ce) {
        throw new RuntimeException(
                "Cannot set destination for child child " + "repository " + childName + " : " + ce);
    }

    try {
        child.init();
    } catch (Exception e) {
        throw new RuntimeException("Cannot initialize child " + "repository " + childName + " : " + e);
    }

    if (DEBUG) {
        getLogger().debug("Child repository of " + m_name + " created in " + m_baseDirectory
                + File.pathSeparatorChar + childName + File.pathSeparator);
    }

    return child;
}