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
2 answers

Runtime.exec command not working

I have a java application that downloads a file from a web service using wget. When executing the command through java it returns with: "wget: not an http or ftp url:" When i execute the command directly it runs without problems. Here is my…
Niek de Gooijer
  • 654
  • 1
  • 9
  • 18
0
votes
1 answer

Wrong exit value from external program

I'm trying to read exit value from external program but it's always 0. String command = ("cmd /c start /wait "+ Script[0]); Process exec = runtime.exec(command); int waitFor =…
0
votes
1 answer

code runs in command prompt but does not run in eclipse

The code given below is the code that i try to run in eclipse which returns stdInput.readLine() as null when i try to run the command through command prompt it runs successfully what am i doing wrong? public class Recognize { public String…
tina
  • 312
  • 1
  • 4
  • 18
0
votes
1 answer

How to use two java.lang.Runtimes in the same Method?

I want to use two Runtime in same method. The second uses the result of the first. I return the results of in two files (*.txt). The result of execution of the first is ok, but the file of the second is empty. The code used is given below: public…
diez
  • 125
  • 1
  • 5
  • 12
0
votes
0 answers

Read/Write to command-line .exe Java

I'm trying to launch a process in java, read the output, write to the program, then read what it responds with. From all the other answers on SO, this is what I have come up with: class Main { public static void main(String[] args) { …
Jason Macgowan
  • 524
  • 7
  • 15
0
votes
1 answer

What was the reason of "access denied" exception while executing Runtime.exec() on Android?

I have native executables compiled for Android and they are located in /data/data/my.app.package so I believe app is able to execute executables there. Unfortunately Runtime.exec() causes an "access denied" exception. How can I know what object…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
0
votes
1 answer

Triggering method from a started jar File which was loaded via Runtime...exec("..") in a java file

this is what I want to do: I need to start two jar Files from out of a java file and i want to call a method from the firstly started jar file, when i read a specific status from the second jar file. I figured out how to read the outsputstream from…
gemorra
  • 142
  • 13
0
votes
3 answers

Process.= Runtime.getRuntime().exec() not working for me

when im executing linux command from java its not working can any one help me about this problem. process3 = Runtime.getRuntime().exec(new String[] {"ls", "-1s", "--block-size=1", …
Civa
  • 2,058
  • 2
  • 18
  • 30
0
votes
1 answer

Storing the o/p of Runtime.getRuntime().exec(command);

I am new to java..... I have 3 files in the zip folder, which I m extracting it using String command = "cmd /c start cmd.exe /K \"jar -xvf record.zip\""; Process ps= Runtime.getRuntime().exec(command); I need to store all the three files…
user2181047
  • 1
  • 1
  • 4
0
votes
1 answer

Running command line on a remote machine using Java

Is it possible to run command line on a remote machine (not on the server machine where the application is hosted). I understand Runtime.getRuntime().exec(".."); will try to run the script on the server machine. Is my understanding correct and is…
hop
  • 2,518
  • 11
  • 40
  • 56
0
votes
1 answer

Runtime.getRuntime().exec() work incorrect

I try to run python application on Android in my application. This script work correct in Better Terminal Emulator Pro su busybox chroot /data/local/debian /bin/bash /usr/bin/python /usr/src/script.py Then I enter value >>value1 result But if I…
0
votes
1 answer

Error passing filename in Runtime.getRuntime().exec(...)

I'm trying to compile a python file from a java program. When I pass the file name directly it works fine. But when i try to pass a string containing the file name in the function I get an error. I need to pass a string containing the file name…
0
votes
1 answer

executing hadoop example jar files from java

I am working with Hadoop 1.0.3 on Ubuntu 12.04, Eclipse 3.7 and am developing a GUI to execute Hadoop jobs using Windowbuider Pro. I need to execute the jar files containing my codes from the GUI. I have used the runtime.getruntime.exec() method…
0
votes
1 answer

Execute ".bat" file that contains multiple lines from Java

I have a folder named A that contains a .bat file: a.bat. If I wanted to write a .bat file I could write: cd A/ call a.bat and I would see the results, but if I want to run it from Java I have problems. I'm trying to do this: String command =…
Maroun
  • 94,125
  • 30
  • 188
  • 241
0
votes
1 answer

java Runtime.exec python and thread in python not run

python script: import os import subprocess import threading import sys command= sys.argv[1:] command=" ".join(command) def readValue(): print 'start receive command' while True: msg=raw_input() print 'msg received: %s' %…
kdlan
  • 15
  • 4