Questions tagged [processbuilder]
Processbuilder is Java wrapper around an Operating System Process. This class is used to create operating system processes.
1,508
questions
-2
votes
0
answers
18
views
How to stream Audio and Video on rtmp link using processBuilder (ffmpeg)
I am getting audio video data on tcp. Along with that some other data is also there so, my Java program removes that, and I have maintained 2 queues for audio and video, then I stream on rtmp using ...
2
votes
3
answers
42
views
How to have input-redirection with Javas ProcessBuilder?
How can I apply input redirection to Javas ProcessBuilder?
E.g. use cat of Linux
cat x.txt > output.txt
My code
// read x.txt with cat and redirect the output to output.txt
public static void main ...
0
votes
0
answers
28
views
Windows Open With Dialog from Java
I need to call the Windows Open With dialog from my Java code. I used to use this line:
Runtime.getRuntime().exec("RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL " + absolute_file_path)
However, ...
1
vote
1
answer
88
views
Executing a Batch Script with ProcessBuilder
I'm trying to execute a Batch Script with ProcessBuilder and can't figure out why it's not working.
I built a small PoC to show my problem, in order for this to work you would need to create some ...
0
votes
0
answers
31
views
Logging system calls of external Process created by Java with Seccomp
I would like to log all system calls made by a Java application and the processes started from the application with a Seccomp profile. Im running the applcation within a Kubernetes pod and supplying ...
0
votes
0
answers
31
views
Java ProcessBuilder run npm command Not Working
Using Mac Mini Server
My Java Code 1 :
Process p = Runtime.getRuntime().exec("npm");
p.waitFor();
My Java Code 2 :
Process p = new ProcessBuilder("npm run build")
directory(new ...
0
votes
0
answers
106
views
How to resolve this filter Processbuilder error?
not able run this coomand
List<String> command= new ArrayList<>();
command.add("ffmpeg");
command.add("-i");
command.add(file1Path);
command.add(&...
1
vote
0
answers
62
views
Start process in Java which has password prompt
I want to start a process that asks for a password. The password should be provided automatically. I tried:
Process process = processBuilder.start();
Thread.sleep(10000);
OutputStream os = process....
0
votes
0
answers
51
views
How to execute jar file with options using java program?
I am executing following command using java program but not getting result and getting exitCode is 1 with mentioned output.
Command
java -jar openapi-generator-cli.jar generate -g spring -i petstore....
-1
votes
1
answer
31
views
jar executable can't find binary which is included in jar
I'm running a cmd tool from a java app with ProcessBuilder, it's located in src/main/resources/external/name-of-tool/name-of-tool.exe. When I build jar with maven and try to run it I get an ...
0
votes
1
answer
78
views
Running ProcessBuilder as root gives 'No such file or directory'
I have a Java program which record audio using mixer on a Raspberry Pi. I am using ProcessBuilder to achieve this and was working fine last year. Now it doesn't however, and I get the following error ...
-2
votes
1
answer
28
views
Why is Process.getInputStream omitting spaces? [Java 20]
I'm getting the InputStream from a process and printing it like this:
String line = null;
var iStream = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = iStream....
-1
votes
2
answers
81
views
Java: unable to delete file used by ProcessBuilder
I have this code:
try {
// Create a temporary file
Path tmpFilePath = Files.createTempFile("tmp-errors", ".log");
// Create a ProcessBuilder and redirect the error ...
0
votes
0
answers
32
views
Debug Psql block variables from Java Process with Input/Output Streams
I am trying to run a PgSql block from a Java Process. I have the process output stream
where statements are written and process input stream where the result is retrieved from. Example:
["do $$&...
0
votes
0
answers
52
views
ProcessBuilder Throwing IO Exception when executing a batch file more than once
I am trying to run a batch file from my java application using Processbuilder and using an api to call this Processbuilder. When I run the api for the first time the Processbuilder is able to locate ...
0
votes
1
answer
237
views
Running a ProcessBuilder process from inside a SpringBoot application regularly hangs and does not execute the command
First off, this is a SpringBoot application running inside a Docker container.
The application will perform a Liquibase update for each configured tenant. In this case, 3 tenants.
What I find is that ...
-1
votes
1
answer
75
views
I am trying to run a Python script through Java, but I want to run the import lines in Python only once
I am trying to run a Python script through Java, but I want to run the import lines in Python only once since I am importing TensorFlow and spaCy in my Python script. Importing them takes time, so I ...
0
votes
0
answers
175
views
Permission denied when using ProcessBuilder in project directory
I'm trying to use ProcessBuilder to execute a python file within my Java program, however when using ProcessBuilder I am getting error 13: permission denied.
try{
ProcessBuilder pb = new ...
0
votes
0
answers
53
views
Why inputStream randomly comes empty while capturing the output from ProcessBuilder?
I found similar questions here at SO, but no solution worked for me.
My code is
ResultSet rs = stmt.executeQuery();
int ret = 0;
while (rs.next()) {
int rsID = rs.getInt("ID");
...
2
votes
0
answers
39
views
Pipe ("|") doesn't work with ProcessBuilder in Android [duplicate]
I want to search logcat for a specific keyword using grep:
ProcessBuilder(
listOf("logcat", "-d", "|", "grep", "<regex-match>")
).start()....
0
votes
0
answers
63
views
Java ProcessBuilder batch file that calls other batch files
Let's say I have a folder.bat file such as this:
Echo HELLO
cd subfolder
call subfolder.bat
cd ..
Echo HELLO AGAIN!
I have noticed that when the processes run, the subfolder.bat gets it's own ...
0
votes
1
answer
55
views
Java ProcessExplorer is there a way to allow a remote machine to handle the process run?
working on a problem where ProcessBuilder is being used to start a batch file on a remote machine. However I wan't to have the ability to either wait for the processes completion or not. When waiting ...
1
vote
1
answer
131
views
Can't call Gradle with arguments from a java app using Process Builder, build fails
I'm trying to call a Gradle app from a separate java app, on Linux. I'm using ProcessBuilder, which calls the Gradle app no problem when not passing an argument, and the Gradle app builds. But when I ...
0
votes
0
answers
11
views
Is ByteArrayOutputstream to string conversion from process inputstream works faster instead of using StringBuffer
I have been trying to execute commands using java. And I trying to figure a fastest way to convert process inputstream to string. On reading a lot, I found that ByteArrayOutputstream is faster. Is i t ...
1
vote
0
answers
155
views
Why running a PowerShell script is slow inside a JVM multithreaded environment whereas it is faster otherwise?
I'm trying to execute a PowerShell script which retirves Exchange Online mailboxes. When running the script separately in PowerShell prompt and running the script via JAVA class file (in eclipse), the ...
0
votes
0
answers
37
views
How to run a linux command using processbuilder WITHOUT elevated (sudo / root) permissions from an elevated java process?
I am running an elevated java process sudo java -jar ... and i want to be able to execute something using ProcessBuilder but without elevated permissions.
The exact command i want to run is sox -t ...
0
votes
4
answers
593
views
Java: How do I kill a background process automatically when the main application is stopped?
I'm trying to use Java to launch a Gradle process that performs a continuous build in the background. Here is my code:
final var updateTimestampProcess =
new ProcessBuilder("gradlew.bat&...
0
votes
0
answers
395
views
How to fix Java ProcessBuilder "Command Not Found" for Linux-based systems?
--- Specs ---
Operating System: Ubuntu-based Pop OS
OS Version: 22.04
Desktop Environment: default / GNOME
Used OS Shell(s): default / bash & sh
Programming Language: Java 8 / 17
Program ...
0
votes
1
answer
131
views
ProcessBuilder("command","-v","date").start() fails with IOException: No such file or directory
I am trying to find out whether a command exists (eg. date) using the command shell builtin, on Ubuntu. However the following (scroll further below for java snippet)
//main.kt
fun main(){
val ...
0
votes
0
answers
19
views
Java No line found after opening from project.jar
I have a problem after pressing the rebirth button, because the program turns off and on correctly, but when I turn it on again after a few minutes, I get an error:
Exception in thread "main"...
0
votes
1
answer
55
views
Java ProcessBuilder class can't run .py script
I have a program that builds a set of processes that need to execute a main.py script but with different parameters between them. The scripts have the following form:
python C:/Users/us/Git/main.py 2 ...
0
votes
0
answers
50
views
How to cover PAUSE Elements from Process Builder Or Flows?
I have to write a test class for a Process Builder which sends a notification to user at certain time which is equal to a date and time field (scheduled Date and Time)in Opportunity so there is a ...
0
votes
1
answer
128
views
Java ProcessBuilder not executing git checkout command
I want to execute 4 commands using ProcessBuilder however 2nd command is not working properly.
My code:
public static void main(String[] args) {
String path_prj = "C:\\Users\\asali\\Desktop\\...
2
votes
1
answer
4k
views
Problem trying to run Github CLI command gh auth login --with-token from Java
I'm having trouble automating authentication to github cli from java.
I'm able to run the following from the cmd line in windows:
gh auth login --with-token < C:\path\to\my\github-api-token.txt
...
0
votes
2
answers
42
views
ProcessBuilder produces different output compared to terminal with the same command
I’m trying to send a broadcast command with ProcessBuilder. It “works”, but the output is different if I run the same command via terminal:
adb shell am broadcast -p com.sample -a sample.action -e &...
0
votes
0
answers
45
views
Java - Tomcat Does not Launch ProcessBuilder() -- Password encryption
I created a "SecureUtils" method which will launch a .bat file to hash a password and return it as a string in Java. This method works very well on its own (with a main() to test it), but as ...
0
votes
0
answers
39
views
Is there a way to 'bring to front' a window that is started using ProcessBuilder object?
I am trying to automatically start processes and open the applications using Java ProcessBuilder. When I run the script, the process starts and the window is opened in the background. How can I bring ...
0
votes
1
answer
143
views
Can I call an arm64 Process using BuildProcess in Java?
I am trying to call some terminal commands from Java using the Java ProcessBuilder with an M1 Mac that uses arm64. However, even though that I am using arm64 compatible JVM (Zulu 11, 17..) that ...
0
votes
1
answer
78
views
Force BufferedInputStream to return captured content
I have a Spring Boot REST application with 2 endpoints: first starts the Process (db shell) with a command like 'mysql -e root'. Second one accepts command (query) and writes it to OutputStream (which ...
0
votes
1
answer
249
views
How to get InputStream from underlying process when using Java Process
I'm not able to get command execution result from Java process.getInputStream() from processes underlying process. That is 'cmd.exe' is called (or any other terminal), then 'mysql\n' is typed, so we ...
0
votes
0
answers
112
views
taskkill command works with cmd but not working in java code to end process tree
when I type taskkill /f /t /pid xxx in Command Prompt, my process tree ends correctly. However, the code block below written in Java ends all processes in my process tree except one of them. Could you ...
0
votes
0
answers
398
views
Reducing CPU usage with ProcessBuilder and BufferedWriter
I have a piece of code which uses ProcessBuilder to run a shell command [cURL] and the response from the command is pretty huge [webpage content].
I am utilising the BufferedReader to read the ...
0
votes
0
answers
372
views
ClassNotFoundException found while loading classes from extension classloader using java
I am using processbuilder to run specific task in seperate JVM instance. i have two directory lib and conflictlib. lib directory i have added under classpath and conflictlib i have added in "java....
0
votes
0
answers
57
views
msi installer is not working with apache commons exec throws exit code 1639
I am trying to install a software with .msi file and it is working fine when I try in the Windows command prompt. But the same is not working in apache commons exec. When I run thru apache commons ...
0
votes
1
answer
460
views
Executing curl command with ProcessBuilder and bearer token
I am trying to execute a curl PUT request which contains a bearer token for the authorization header, using ProcessBuilder. There is some issue with how ProcessBuilder is parsing the quotes for the ...
-1
votes
1
answer
68
views
Error when creating zstd file with ProcessBuilder on Java
I'm trying to use ProcessBuilder in order to create a tar.zst file that compresses a folder. However, I'm getting the following error after running this code:
try {
ProcessBuilder pb = new ...
1
vote
0
answers
177
views
Interprocess communication Java
I'm currently learning Java interprocess communication and it's being pretty tough for me. I need to develop a Java program that supports parameters from the console call line and return the following ...
0
votes
1
answer
166
views
How to run a batch file with arguments in administrator mode from JavaSwing button using process builder?
I am creating a Java Swing application where I am taking input from user which will be used as arguments for a batch file.
After pressing a button, my batch file should get launched in ADMIN mode ...
0
votes
0
answers
80
views
ProcessBuilder SFTP Java Linux
I am trying to send a csv file by calling a sh file. But it does not detect the sh file in the path of the linux machine. For now I just want to get to that file. Then I would have to pass parameters ...
0
votes
0
answers
81
views
Java NoClassDefFoundError when calling method from .jar executable with ProcessBuilder
I user ProcessBuilder to run ProcessF.java as an independent process:
Main:
ProcessBuilder pb = new ProcessBuilder("java", "os.ProcessF");
pb1.directory(new File("C:\\DOCS\\...