本文整理汇总了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;
}
示例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;
}
示例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;
}