apache-commons-exec

PumpStreamHandler can capture the process output in realtime

微笑、不失礼 提交于 2019-12-12 04:04:56
问题 I try to capture a python process output via apache-commons-exec. But it looks like it won't print the output, the output is only displayed after I the python process is finished. Here's my java code CommandLine cmd = CommandLine.parse("/Users/jzhang/anaconda/bin/python"); cmd.addArgument("/Users/jzhang/a.py"); DefaultExecutor executor = new DefaultExecutor(); ExecuteWatchdog watchDog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT); executor.setWatchdog(watchDog); executor.execute(cmd

How to run a java program using apache commons-exec?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 02:26:52
问题 I am trying to run java code dynamically in my java application GUI. I have tried the following code: Sring tempfile="java -classpath "+wrkdir+"/bin "+runfile; CommandLine cmdLine = CommandLine.parse(tempfile); DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); ExecuteWatchdog watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT); DefaultExecutor executor = new DefaultExecutor(); executor.setExitValue(1); executor.setWatchdog(watchdog); try { executor

Process Object from Apache Commons Exec

淺唱寂寞╮ 提交于 2019-12-11 07:01:29
问题 I'm using the Apache Commons Exec jars for creating processes. However I'd like to get control of the process id of processes being invoked. Is there a way of getting the 'Process' object from the Apache Commons Exec api? I did'nt fine any public methods that returns the 'Process class. 回答1: See http://commons.apache.org/exec/apidocs/index.html Interface CommandLauncher contains several exec methods that return Process . But anyway you do not have any way to control the process ID: it is the

commons-exec: hanging when I call executor.execute(commandLine);

六月ゝ 毕业季﹏ 提交于 2019-12-10 20:09:42
问题 I have no idea why this is hanging. I'm trying to capture output from a process run through commons-exec, and I continue to hang. I've provided an example program to demonstrate this behavior below. import java.io.DataInputStream; import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.ExecuteException; import org.apache.commons.exec

Executing an external program using process builder or apache commons exec

余生颓废 提交于 2019-12-07 13:25:59
问题 I need to execute an external application which returns large data (takes more than 2 hours to complete ) nand which continuously outputs data. What I need to do is execute this program asynchronously and capture the output in a file. I tried using java process builder, however it seems to hang and return output only when the program is exited or forcefully terminated. I tried to use process builder and spwaned a new thread to capture the output, but still it did not help. Then I read about

Executing an external program using process builder or apache commons exec

ⅰ亾dé卋堺 提交于 2019-12-06 01:03:04
I need to execute an external application which returns large data (takes more than 2 hours to complete ) nand which continuously outputs data. What I need to do is execute this program asynchronously and capture the output in a file. I tried using java process builder, however it seems to hang and return output only when the program is exited or forcefully terminated. I tried to use process builder and spwaned a new thread to capture the output, but still it did not help. Then I read about apache commons exec and tried the same . however this also seems to be taking a long time and returns

“Kill a process tree” on windows using Java

白昼怎懂夜的黑 提交于 2019-12-01 05:46:56
I have a Java webstart process that is part of a windows batch script. I'm using the javaws command in a batch script in this case. This match script ( start.bat) is invoked programatically using the "apache commons exec". Under some conditions the java process invoked by javaws hangs and I'd have to kill the entire process thread starting from the batch script start.bat. Is there a programatic way of doing killing an entire process tree through apache commons exec? I've tried using the "execWatchdog.destroyProcess();" on the "start.bat" script. However it only kills the start.bat process and

Apache Commons Exec produces too many quotes for arguments containing spaces?

♀尐吖头ヾ 提交于 2019-11-30 23:51:26
问题 Either there is a bug in Apache Commons Exec, or I am using the API wrong, but when I use the CommandLine class to add a argument that contains spaces, some quotes are added and are then part of the argument that is given. For example: When I call java "what version" I get java.lang.NoClassDefFoundError: what version , and when I call java "\"what version\"" (which contains escaped quotes, that are part of the command line argument itself), I get java.lang.NoClassDefFoundError: "what version"

Trouble providing multiple input to a Command using Apache Commons Exec and extracting output

柔情痞子 提交于 2019-11-30 13:49:01
I am writing a Java application that needs to use an external command line application using the Apache Commons Exec library. The application I need to run has a fairly long loading time so it would be preferable to keep one instance alive instead of creating a new process every time. The way the application work is very simple. Once started, it waits for some new input and generates some data as an output, both of which use the application's standard I/O. So the idea would be to execute the CommandLine, and then to use the PumpStreamHandler with three separate streams (output, error and input

Trouble providing multiple input to a Command using Apache Commons Exec and extracting output

ⅰ亾dé卋堺 提交于 2019-11-29 19:29:35
问题 I am writing a Java application that needs to use an external command line application using the Apache Commons Exec library. The application I need to run has a fairly long loading time so it would be preferable to keep one instance alive instead of creating a new process every time. The way the application work is very simple. Once started, it waits for some new input and generates some data as an output, both of which use the application's standard I/O. So the idea would be to execute the