本文整理汇总了Java中org.netbeans.api.extexecution.ExternalProcessBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ExternalProcessBuilder类的具体用法?Java ExternalProcessBuilder怎么用?Java ExternalProcessBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExternalProcessBuilder类属于org.netbeans.api.extexecution包,在下文中一共展示了ExternalProcessBuilder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: executeEclipseCommand
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
public static void executeEclipseCommand(PlayProject playProject) {
try {
addEclipseSBTPluginIfNeeded(playProject);
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.inputVisible(true)
.showProgress(true);
ExternalProcessBuilder processBuilderEclipseCommand = new ExternalProcessBuilder(PlayProjectUtil.getActivatorExecutablePath())
.workingDirectory(new File(playProject.getProjectDirectory().getPath()))
.addArgument("eclipse");
processBuilderEclipseCommand = PlayProjectUtil.addJavaHomeVariable(processBuilderEclipseCommand);
ExecutionService serviceEclipseCommand = ExecutionService.newService(processBuilderEclipseCommand,
descriptor,
"Configuring (" + playProject.getProjectName() + ") Classpath");
Future<Integer> eclipseCommandFuture = serviceEclipseCommand.run();
eclipseCommandFuture.get(); //wait for this to finish before leave this method
} catch (InterruptedException | ExecutionException ex) {
ExceptionManager.logException(ex);
}
}
示例3: detectDefaultWebBrowser
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
private static String detectDefaultWebBrowser() {
// XXX hotfix for #233047
// assert !EventQueue.isDispatchThread();
// #233145
if (!XDG_SETTINGS_AVAILABLE) {
return null;
}
OutputProcessorFactory outputProcessorFactory = new OutputProcessorFactory();
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(XDG_SETTINGS_COMMAND) // NOI18N
.addArgument("get") // NOI18N
.addArgument("default-web-browser"); // NOI18N
ExecutionDescriptor silentDescriptor = new ExecutionDescriptor()
.inputOutput(InputOutput.NULL)
.inputVisible(false)
.frontWindow(false)
.showProgress(false)
.outProcessorFactory(outputProcessorFactory);
Future<Integer> result = ExecutionService.newService(processBuilder, silentDescriptor, "Detecting default web browser") // NOI18N
.run();
try {
result.get(10, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
LOGGER.log(Level.INFO, null, ex);
}
String output = outputProcessorFactory.getOutput();
if (output == null) {
return null;
}
return output.toLowerCase(Locale.US);
}
示例4: actionPerformed
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ev) {
FileObject fileObject = context.getPrimaryFile();
String fileDisplayName = FileUtil.getFileDisplayName(fileObject);
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.showProgress(true)
.inputVisible(true)
.controllable(true)
.preExecution(() -> {
try {
Runtime.getRuntime().exec("chmod +x " + fileDisplayName).waitFor();
} catch (IOException | InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
LifecycleManager.getDefault().saveAll();
});
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(fileDisplayName);
ExecutionService service = ExecutionService.newService(
processBuilder, descriptor, fileDisplayName);
service.run();
}
示例5: 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;
}
示例6: 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;
}
示例7: launchEmulator
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
public Future<IDevice> launchEmulator(AvdInfo avdInfo, LaunchConfiguration launchCfg) {
final String cookie = Long.toString(System.currentTimeMillis());
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true);
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(getEmulatorBinaryPath())
.addArgument(FLAG_AVD).addArgument(avdInfo.getName())
.addArgument(FLAG_PROP).addArgument(LAUNCH_COOKIE + "=" + cookie);
// TODO support quoting
for (String arg : Splitter.on(' ').omitEmptyStrings().split(launchCfg.getEmulatorOptions())) {
processBuilder = processBuilder.addArgument(arg);
}
ExecutionService service = ExecutionService.newService(
processBuilder, descriptor, "Android emulator");
Future<Integer> taskStatus = service.run();
return EXECUTOR.submit(new Callable<IDevice>() {
@Override
public IDevice call() throws Exception {
synchronized (connectLock) {
while (true) {
for (IDevice device : connectedDevices) {
if (device.isOnline()) {
ProgressHandle handle = ProgressHandle.createHandle("Emulator starting");
handle.start();
while (true) {
String property = device.getSystemProperty("sys.boot_completed").get();
if (property != null) {
break;
}
}
handle.finish();
LOG.log(Level.INFO, "Started emulator device connected.");
return device;
}
}
connectLock.wait();
}
}
}
});
}
示例8: instantiate
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
@Override
public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException {
Set<FileObject> resultSet = new LinkedHashSet<>();
String activatorInstallationDir = NbPreferences.forModule(PlayPanel.class).get(ACTIVATOR_EXECUTABLE_PATH, "");
if (!activatorInstallationDir.trim().isEmpty()) {
String activatorExecutablePath = activatorInstallationDir + "/" + PlayProjectUtil.getActivatorCommandString();
File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
dirF.mkdirs(); //create all subdirectories if they don't exists of this project dir
dirF.delete(); //delete the current app dir because activator will create this folder
String appName = (String) wiz.getProperty("name");
File parent = dirF.getParentFile();
String templateName = (String) wiz.getProperty("templateName");
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.showProgress(true);
String commandTitle = "activator new " + appName + " " + templateName;
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(activatorExecutablePath)
.workingDirectory(parent)
.addArgument("new")
.addArgument(appName)
.addArgument(templateName);
processBuilder = PlayProjectUtil.addJavaHomeVariable(processBuilder);
ExecutionService service = ExecutionService.newService(processBuilder, descriptor, commandTitle);
Future<Integer> futureRun = service.run();
Integer exitValue;
try {
exitValue = futureRun.get();
if (exitValue == 0) {
FileObject dir = FileUtil.toFileObject(new File(
parent.getAbsolutePath() + "/" + appName));
resultSet.add(dir);
}
} catch (InterruptedException | ExecutionException ex) {
ExceptionManager.logException(ex);
}
//Sets the folder last used for creating a new project.
if (parent != null && parent.exists()) {
ProjectChooser.setProjectsFolder(parent);
}
}
return resultSet;
}
示例9: executeAction
import org.netbeans.api.extexecution.ExternalProcessBuilder; //导入依赖的package包/类
public void executeAction(ActionsEnum action, Optional<String> param1Optional) {
try {
if (PlayProjectUtil.isActivatorExecutablePathSpecified()) {
String projectName = playProject.getProjectName();
if (action.isStandard) {
closePreviousTabs(projectName);
ExecutionDescriptor descriptor = new ExecutionDescriptor()
.frontWindow(true)
.showProgress(true)
.inputVisible(true)
.preExecution(() -> LifecycleManager.getDefault().saveAll())
.controllable(true);
ExternalProcessBuilder processBuilder = new ExternalProcessBuilder(PlayProjectUtil.getActivatorExecutablePath())
.workingDirectory(new File(playProject.getProjectDirectory().getPath()));
processBuilder = PlayProjectUtil.addJavaHomeVariable(processBuilder);
String commandString = getCommandString(action);
String[] arguments;
if (param1Optional.isPresent()) {
String argumentTemp = commandString.replace("${param1}", param1Optional.get());
if (action.equals(ActionsEnum.TEST_ONLY) || action.equals(ActionsEnum.TEST_ONLY_AUTOCOMPILE)) {
arguments = new String[]{argumentTemp};
} else {
arguments = argumentTemp.split(" ");
}
} else {
arguments = commandString.split(" ");
}
for (String argument : arguments) {
processBuilder = processBuilder.addArgument(argument);
}
String displayName = getTabDisplayName(projectName, action, param1Optional);
ExecutionService service = ExecutionService.newService(processBuilder,
descriptor, displayName);
StatusDisplayer.getDefault().setStatusText("(" + projectName + ") Executing SBT TASK: [" + commandString + "]");
service.run();
if (action.equals(ActionsEnum.DEBUG_AUTOCOMPILE)
|| action.equals(ActionsEnum.DEBUG)) {
attachDebugger();
}
} else {
switch (action) {
case RELOAD_PROJECT:
playProject.getClassPathProviderImpl().reloadProject();
break;
case SBT_SCOVERAGE:
ActionsHelper.runSBTSCoverage(playProject);
break;
case JACOCO4SBT:
ActionsHelper.runJacoco4sbt(playProject);
break;
default:
break;
}
}
} else {
PlayProjectUtil.openPlayFrameworkOptionWindow();
}
} catch (Exception ex) {
ExceptionManager.logException(ex);
}
}