Questions tagged [runtime.exec]

The Runtime.exec() method allows Java apps. to create a new OS Process.

The Runtime.exec(...) method (which has 6 overloaded variants) allows Java apps. to create a new system (represented in Java as a Process).

There are common mistakes made when creating new processes - as detailed in When Runtime.exec() won't. The article is the first thing to check if a process fails. Implement all the tips, and even if doing so does not make the process work, it will provide much more detailed information on why it failed.

The ProcessBuilder class introduced in Java 1.5 makes it easier to create and use a process correctly. For example, the redirectErrorStream(boolean) convenience method will merge the System.out & System.err streams, which allows both streams to be consumed in one Thread.

881 questions
0
votes
0 answers

Runtime.getruntime.exec will not return anything when executing sesearch command

This is a common problem from what I see, but I tried to incorporate some of the suggestions provided. None worked for me. Am I making a mistake here? This is what I am trying to do. String[] comd1 = { "/bin/sh", "-c", "sesearch", "--allow -s…
0
votes
1 answer

Run exe using Java as administrator

How to run exe file as administrator if you know admin login and password? I have tried with Runtime.getRuntime().exec("runas /profile /user:Administrator \"cmd.exe /c Powrprof.dll,SetSuspendState\""); but it asks for password, I want to write…
Madi Sagimbekov
  • 319
  • 5
  • 15
0
votes
0 answers

Starting java .app in java via Runtime.getRuntime().exec crashes with 'Program quit unexpectedly'

I want to start an .app Application in java on a Mac OS X 10.7.5 with the following code: Runtime.getRuntime().exec(new String[] { "/usr/bin/open", filename }); The filename contains the physical path and the filename. If I start the filename…
0
votes
2 answers

how to execute console commands in a java program for node

I need to access the console on the node through java how to make this ? public class Comando { public static void main(String[] args) { String comando = "C:\\Program Files\\nodejs\\node.exe"; try { Process process =…
0
votes
1 answer

How to execute sh file without wait result?

I have a problem, I tried run a sh file from java code to start a JBoss Server, so when I exec this sh file I want to know when it's started and print out my console. Here is my code: public static void runStart() { try { …
0
votes
3 answers

How to read the output of an exec process in Java?

Writing some Java code for running a text executable file under Linux, I have a problem to print out the output of it. This executable file is actually a nmap -sP and so receives to parameters. Everytime I call for the compiled class, I only can see…
diegoaguilar
  • 8,179
  • 14
  • 80
  • 129
0
votes
2 answers

Get Finder Selection directly in Java without any help of Applescript

Is it possible to get the Finde-Selection directly in Java without any help of Applescipt? Basically its possible by executing an osascript in Java which calls another applescript that passes the Finder-selection as a string. thx. import…
domizai
  • 343
  • 1
  • 5
  • 13
0
votes
1 answer

exec call returns 125

What could be wrong here, so i get always the exitValue 125? : function cPWinKerb(userPW,userUID) { try { var execStr = new Array("su","-c","/home/shellscript.sh",userPW,userUID); var runtime = java.lang.Runtime.getRuntime(); var proc =…
MaiLo
  • 87
  • 1
  • 9
0
votes
1 answer

Dialog with changing text in swing

I am developing a swing application in which I am running a cmd command using Runtime.getRuntime.execute(); and reading the output of command using BufferReader. Now what I want is I want to show the output in dialog with changing the text(Using…
Piyush Agarwal
  • 25,608
  • 8
  • 98
  • 111
0
votes
0 answers

external directory is malformed when converting from URL to File

I'm currently trying to execute a cmd in an external directory using ProcessBuilder. When I convert my URL to a File, a method in the File class that removes redundancies (File.fs.normalize) is called and reduces the "//" that I need in the…
olivialarson
  • 31
  • 1
  • 6
0
votes
2 answers

Compressing and Archiving the files in the folder using Java Runtime

I am trying to Compress and Archive all the files in a folder, using Java Runtime class. My code snippet looks as this : public static void compressFileRuntime() throws IOException, InterruptedException { String date =…
Amit
  • 435
  • 2
  • 8
  • 16
0
votes
1 answer

How to run certain Processes depending on user input and then destroy them accordingly?

So for example: Runtime rt = Runtime.getRuntime(); creates Runtime rt Process p1 = rt.exec("C:/Windows/System32/calc.exe"); creates Process p1 on Runtime rt. Then p1.destroy(); will destroy Process p1. My question is: If I have more than one Process…
knorberg
  • 462
  • 5
  • 19
0
votes
1 answer

How to destroy all Processes from a Runtime at once?

So for example: Runtime rt = Runtime.getRuntime(); creates Runtime rt Process p1 = rt.exec("C:/Windows/System32/calc.exe"); creates Process p1 on Runtime rt. Then p1.destroy(); will destroy Process p1. My question is: If I have more than one Process…
knorberg
  • 462
  • 5
  • 19
0
votes
0 answers

Send input to a process

I have this code which is working fine. How to send my input to the Java Process Builder? Here is the code: PrintStream out = System.out; Runtime rt = Runtime.getRuntime(); try { out.println("Executing a command in a separate process..."); …
Vahe
  • 96
  • 3
0
votes
1 answer

How to store a file in Java, which is generated on execution of a .exe file?

I have a .exe file, which produces certain files when made to run : The files produced are WatchDataTest, ngrtgs.test, shubhangi, slatey (as they appear in the image) I want to run the .exe file through a separate Java Program and obtain reference…
jigsawmnc
  • 444
  • 5
  • 15