当前位置: 首页>>代码示例>>Java>>正文


Java ExternalProcessBuilder.addEnvironmentVariable方法代码示例

本文整理汇总了Java中org.netbeans.api.extexecution.ExternalProcessBuilder.addEnvironmentVariable方法的典型用法代码示例。如果您正苦于以下问题:Java ExternalProcessBuilder.addEnvironmentVariable方法的具体用法?Java ExternalProcessBuilder.addEnvironmentVariable怎么用?Java ExternalProcessBuilder.addEnvironmentVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.api.extexecution.ExternalProcessBuilder的用法示例。


在下文中一共展示了ExternalProcessBuilder.addEnvironmentVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jreCreate

import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入方法依赖的package包/类
private static int jreCreate(@NonNull final List<String> cmdLine) {
    ExternalProcessBuilder pb = new ExternalProcessBuilder(cmdLine.get(0));
    pb = pb.addEnvironmentVariable(
        ENV_JAVA_HOME,
        FileUtil.toFile(JavaPlatform.getDefault().getInstallFolders().iterator().next()).getAbsolutePath());
    for (String arg : cmdLine.subList(1, cmdLine.size())) {
        pb = pb.addArgument(arg);
    }
    int res;
    try {
        final Process process = pb.call();
        try (BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
            String line;
            while ((line = in.readLine())!= null) {
                System.out.println(line);
            }
        }
        process.waitFor();
        res = process.exitValue();
    } catch (IOException | InterruptedException e) {
        res = -1;
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SetUpRemotePlatform.java

示例2: addJavaHomeVariable

import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入方法依赖的package包/类
public static ExternalProcessBuilder addJavaHomeVariable(ExternalProcessBuilder processBuilder) {
    String jdkHomeValue = System.getProperty(PlayProjectUtil.JDK_HOME);
    
    GestureManager.registerGesture(Level.INFO, "1- jdk.home:"+jdkHomeValue, null);
    if (jdkHomeValue != null) {
        processBuilder = processBuilder.addEnvironmentVariable("JAVA_HOME", jdkHomeValue);
    }
    return processBuilder;
}
 
开发者ID:pedrohidalgo,项目名称:pleasure,代码行数:10,代码来源:PlayProjectUtil.java

示例3: buildProcess

import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入方法依赖的package包/类
public ExternalProcessBuilder buildProcess() throws IOException
{
    ExternalProcessBuilder processBuilder =
            new ExternalProcessBuilder(command);
    if (workingDirectory == null)
    {
        workingDirectory = new File(System.getProperty("user.home")).getAbsolutePath();
    }
    for (String name : envVars.keySet())
    {
        String value = envVars.get(name);
        if (JOTUtilities.isWindowsOS())
        {
            value = value.replace("\\", "\\\\");
        }
        processBuilder = processBuilder.addEnvironmentVariable(name, value);
    }

    processBuilder = processBuilder.workingDirectory(FileUtil.normalizeFile(new File(workingDirectory)));
    for (int i = 0; i != commandArgs.size(); i++)
    {
        String arg = commandArgs.get(i);
        if (arg != null && arg.trim().length() > 0)
        {
            if (JOTUtilities.isWindowsOS())
            {
                arg = arg.replace("\\", "\\\\");
            }
            processBuilder = processBuilder.addArgument(arg);
        }
    }

    processBuilder = processBuilder.redirectErrorStream(redirect);
    return processBuilder;
}
 
开发者ID:tcolar,项目名称:fantomidemodule,代码行数:36,代码来源:FanExecution.java


注:本文中的org.netbeans.api.extexecution.ExternalProcessBuilder.addEnvironmentVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。