Questions tagged [processbuilder]

Processbuilder is Java wrapper around an Operating System Process. This class is used to create operating system processes.

From the Javadoc:

Each ProcessBuilder instance manages a collection of process attributes. The start() method creates a new Process instance with those attributes. The start() method can be invoked repeatedly from the same instance to create new subprocesses with identical or related attributes.

1509 questions
10
votes
3 answers

Start CMD by using ProcessBuilder

I am trying to start the CMD application in windows by using the following code, but it doesn't work as expected. Several examples from different websites shows that "cmd" as an argument in the ProcessBuilder construct should work. What do I have to…
Birdman
  • 5,244
  • 11
  • 44
  • 65
9
votes
1 answer

Redirecting Output of ProcessBuilder in Java 5/6?

I am looking for a way to redirect the output of a Process / ProcessBuilder? I know that it works in Java 7 like this: ProcessBuilder builder = new ProcessBuilder(command); builder.redirectOutput(); Process process = builder.start(); But I need the…
salocinx
  • 3,715
  • 8
  • 61
  • 110
9
votes
2 answers

How to get processbuilder command before execution

I want to know the command that will be executed before it happens. String cmd[] = {"curl", "-X", "POST", "https://api.renam.cl/medicion/insert?access-token={Yoq3UGQqDKP4D1L3Y6xIYp-Lb6fyvavpF3Lm-8cD}", …
9
votes
1 answer

ProcessBuilder vs Runtime.exec()

I'm trying to create a frontend app in Java to handle batch SVG conversions using Inkscape's command line feature. I'm taking and updating the code from https://sourceforge.net/projects/conversionsvg/. The way the original developer handled calling…
9
votes
4 answers

Windows REG command not working when executed from ProcessBuilder in Java

I'm trying to use Java to create a start up registry key and I'm getting a really weird result. On some OS's such as XP the command works flawlessly. However, on Windows 7 it only creates the key if you run the compiled jar or classes, and not from…
Colby
  • 452
  • 4
  • 19
9
votes
3 answers

How do I Pipe process output to a file on Windows and JDK 6u45

I have the following windows batch file (run.bat): @echo off echo hello batch file to sysout And the following java code, which runs the batch files and redirects output to a file: public static void main(String[] args) throws IOException { …
Barak
  • 3,066
  • 2
  • 20
  • 33
9
votes
1 answer

Unrecognized option: -cp with ProcessBuilder on Windows only

So I am working on a cross platform bootstrap program which works correctly on OSX/Linux but returns the following error message in Windows: Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will…
user1698672
  • 93
  • 1
  • 3
9
votes
4 answers

Process Builder waitFor() issue and Open file limitations

I have inherited some code: Process p = new ProcessBuilder("/bin/chmod", "777", path).start(); p.waitFor(); Basically, there is for some ancient and highly voodoo based reason for storing key/value pairs on disk as files. I don't really want to go…
lsl
  • 4,371
  • 3
  • 39
  • 54
8
votes
2 answers

Building a process pipe with ProcessBuilder in Java 7

I've been trying to figure out how to pipe a few processes in Java using the new ProcessBuilder. I can't find a suitable example of what I want to do and when I try to do it myself the process just hangs. I would appreciate a very simple example of…
Aleksandar Savkov
  • 2,894
  • 3
  • 24
  • 30
8
votes
2 answers

Error initializing complex filters. Invalid argument error when running ffmpeg from Kotlin

I'm creating a wrapper for ffmpeg, and it has the following methods: fun executeCommand(args: Array): AppRunner.AppResult { return appRunner.run(ffmpegPath, args) } class AppRunner { fun run( app: String, args:…
artem
  • 16,382
  • 34
  • 113
  • 189
8
votes
3 answers

Java run async processes

I am trying to run an async process and I do not want the program to wait until the end of these processes executions. I found this question how to run shell script asynchronously from within Java program but it doesn't have the answer that I am…
Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103
8
votes
5 answers

Process requires redirected input

I have a UNIX native executable that requires the arguments to be fed in like this prog.exe < foo.txt. foo.txt has two lines: bar baz I am using java.lang.ProcessBuilder to execute this command. Unfortunately, prog.exe will only work using the…
initialZero
  • 6,197
  • 9
  • 29
  • 38
8
votes
2 answers

How to Terminate a Process Normally Created using ProcessBuilder

I am creating Processes using ProcessBuilder in my Java Application. The created process executes some FFMPEG commands which actually copy the RTSP streams in specified destination media file. ProcessBuilder builder = new ProcessBuilder("ffmpeg",…
Bilal Ahmed Yaseen
  • 2,506
  • 2
  • 23
  • 48
8
votes
3 answers

ProcessBuilder not behaving properly with multiple arguments

I have a ProcessBuilder: String src = c:/hello/ String dst = c:/hello/2 ProcessBuilder builder = null; builder = new ProcessBuilder("c:/file/file.exe", "-i", src, "-f", "-l 500", dst); builder.redirectErrorStream(true); process =…
Omid
  • 823
  • 1
  • 11
  • 31
8
votes
4 answers

Sharing objects across Java processes

I am executing another JVM (java.exe) from the main application. Is there any way to share an object (rather large object) with the newly created process (at the time of creation or after it was created). someObject sO= new someObject(); //sO is…
user174819
  • 101
  • 1
  • 4