processbuilder

Run Executable In Jar With ProcessBuilder [duplicate]

天涯浪子 提交于 2019-12-01 11:06:42
This question already has an answer here: Is it possible to jar up an executable so that it can be run from Java? 1 answer I have an application I've built that uses a non-Java executable that it calls via ProcessBuilder: ProcessBuilder pb = new ProcessBuilder(invocation); pb.redirectErrorStream(true); Process proc = pb.start(); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); However, I'd like to bundle that app neatly into the jar file itself, instead of requiring it be placed outside in the same directory

Run Executable In Jar With ProcessBuilder [duplicate]

早过忘川 提交于 2019-12-01 09:11:21
问题 This question already has an answer here : Is it possible to jar up an executable so that it can be run from Java? (1 answer) Closed 3 years ago . I have an application I've built that uses a non-Java executable that it calls via ProcessBuilder: ProcessBuilder pb = new ProcessBuilder(invocation); pb.redirectErrorStream(true); Process proc = pb.start(); InputStream is = proc.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr);

ProcessBuilder cannot find the specified file while Process can

廉价感情. 提交于 2019-12-01 06:49:34
I am trying to run a jar file from a Java program and I succeed using getRuntime() : Process processAlgo = Runtime.getRuntime().exec("java -jar "+algoPath); However when I try using ProcessBuilder I get the The system cannot find the file specified exception: ProcessBuilder builder = new ProcessBuilder("java -jar " + algoPath); Process processAlgo = builder.start(); I tried to change the location of the specified file and also indicated its full path but it won't work. What could cause the problem? ProcessBuilder expects it's parameters to passed in separately. That is, for each command and

ProcessBuilder cannot find the specified file while Process can

我与影子孤独终老i 提交于 2019-12-01 05:04:40
问题 I am trying to run a jar file from a Java program and I succeed using getRuntime() : Process processAlgo = Runtime.getRuntime().exec("java -jar "+algoPath); However when I try using ProcessBuilder I get the The system cannot find the file specified exception: ProcessBuilder builder = new ProcessBuilder("java -jar " + algoPath); Process processAlgo = builder.start(); I tried to change the location of the specified file and also indicated its full path but it won't work. What could cause the

Run a .java file using ProcessBuilder

醉酒当歌 提交于 2019-12-01 03:39:32
问题 I'm a novice programmer working in Eclipse on Windows XP, and I need to get multiple processes running (this is going to be a simulation of a multi-computer system). My initial hackup used multiple threads to multiple classes, but now I'm trying to replace the threads with processes. From my reading, I've gleaned that ProcessBuilder is the way to go. I have tried many many versions of the input you see below, but cannot for the life of me figure out how to properly use it. I am trying to run

Execute a shell command using processBuilder and interact with it

六眼飞鱼酱① 提交于 2019-11-30 23:05:26
I'm trying to create a program allowing me to execute a command through a terminal (which is OmxPlayer for raspberry pi if you want to know) with arguments, but i'd want to be able to interact with it once I have launched the command. For example i'd want to do : omxplayer -win x1 y1 x2 y2 and then be able to press "p" to pause the video/audio media I already have something that can launch the omxplayer with arguments (actually it's "ls" but it should work exactly the same way) but I don't understand how to interact with the terminal once i've launched the command through the processBuilder.

How do I use one Java program, to monitor another Java program's output?

半腔热情 提交于 2019-11-30 14:27:17
问题 Below is diagram that shows what I'm trying to do : it is just 2 programs. One is a simple Child program that writes out integers every 2 seconds, line-by-line . The other is a Parent program that monitors the log file ( just a very basic text file). If the log file doesn't get modified within 5 seconds, then it should restart the Child program (via a batch file ); then continue normally. My code for the child class is here: package fileiotestapplication; import java.io.*; import java.io

How to pipe InputStream to ProcessBuilder

眉间皱痕 提交于 2019-11-30 13:47:53
Please move down to the 2nd update. I didn't want to change the previous context of this question. I'm using wkhtmltoimage from a Java app. The standard way of using it is - path-to-exe http://url.com/ image.png . According to their docs, if we write a - instead of an input URL, the input shifts to STDIN. I'm starting the process using ProcessBuilder - ProcessBuilder pb = new ProcessBuilder(exe_path, " - ", image_save_path); Process process = pb.start(); Now I'm unable to figure out how to pipe an input stream to this process. I have a template file read into a DataInputStream , and I'm

Call an exe from Java with passing parameters with writing to stdout and reading from stdin

旧时模样 提交于 2019-11-30 10:00:11
问题 I have read this question: Java Programming: call an exe from Java and passing parameters And this answer is good enough https://stackoverflow.com/a/5604756/2674303 But I additionally want to pass parameters to stdin of external process and read from stdout of this process. How can I do this? My efforts : main method: public class ProcessBuilderTest { public static void main(String[] args) throws IOException, InterruptedException { ProcessBuilder pb = new ProcessBuilder("C:\\Program Files\

ProcessBuilder and Process.waitFor(), how long does ist wait?

白昼怎懂夜的黑 提交于 2019-11-30 08:59:30
问题 I am executing an .exe-file from java, using the ProcessBuilder class and the Process class. To explain what I am doing: builder = new ProcessBuilder(commands); builder.redirectErrorStream(true); Process process = builder.start(); process.waitFor(); I just wanted to know, for how long is "waitFor()" waiting? Is it waiting until my .exe is executed, or is it waiting till its execution is finished? My .exe is a compiled AutoIt-script. That means, that there could be interactions like mouse