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
1 answer

Unable to build .class file through Runtime class compilation

public void actionPerformed(ActionEvent e) { String sout; try { if(e.getSource()==compile) { sout=input.getText(); Runtime rt=Runtime.getRuntime(); …
tabish
  • 91
  • 1
  • 2
  • 10
0
votes
2 answers

Print Runtime.getRuntime().exec() output live

I'm writing a Java program that is used to call a PHP script in set intervals. The PHP script outputs a lot of data, and it is the client's requirement that the Java program displays all the PHP script's output while the script runs. The method I'm…
aggregate1166877
  • 2,196
  • 23
  • 38
0
votes
2 answers

Compiling C code from a Java program

I am trying the following code to compile an external C program with a Java program import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public static void main(String[] args){ try{ Runtime…
0
votes
1 answer

Calling a .Net Window-based application using Runtime.getRuntime().exec from a Spring Controller running on Tomcat

I am calling an exe file called myapp.exe via a Spring Controller; here is the code in the controller: Runtime.getRuntime().exec("D:\vmd\apps\myapp.exe"); myapp.exe is a C# .NET application. If I click directly on myapp.exe using Windows Explorer,…
Amar Premsaran Patel
  • 1,293
  • 7
  • 17
  • 26
0
votes
5 answers

Run Java program into another Program

Possible Duplicate: Execute another jar in a java program I try to run a jar file of with a java application from within another java application, but I cannot get it to work. My code is below // run Jar in other java application Runtime…
user1508234
  • 7
  • 1
  • 5
0
votes
1 answer

Runtime exec pauses half way through execution

I'm running a Java (.jar) program from a bat script that near the end has the following (on windows) Runtime.getRuntime().exec("svn co http://myrepository.com/someproj"); Thread.sleep(20000); It checks out about 1/10th of the directories and 1 file…
David Witherspoon
  • 673
  • 2
  • 6
  • 13
0
votes
3 answers

Understanding StreamGobbler

I am implementing a mailx command through Runtime.exec and came across this article which explains the right way of doing it. JavaWorld : Runtime.exec I have been through the examples and see that they have introduced a new class StreamGobbler which…
Vivek
  • 2,091
  • 11
  • 46
  • 61
0
votes
2 answers

Java Help(FileStream)

I want to execute notepad(C:\a.txt) after typing another char. This code open a.txt with notepad but when i was write "Java" , i want to show my console Java. after when i was write " then Java" i want to show my console Java then Java". Process…
kibar
  • 822
  • 3
  • 17
  • 37
0
votes
2 answers

Feeding commands to WinSCP

I have Java Code that launch process of WinSCP tool and connects to a Unix machine and then call a xxxx.exe located on the Unix machine. The problem is that xxxx.exe accepts a parameter of a type File. So I need to upload this to the remote machine…
Gerard
  • 65
  • 1
  • 6
0
votes
1 answer

Runtime.exec - fine for 'echo' 'but not for cat...

I'm having a problem calling some simple command line functions with r.exec - for some reason, given a file X the command 'echo full/path/to/X' works fine (both in the display and with 'p.exitValue()==0', but 'cat full/path/to/X' does not (and has…
Joe
  • 4,367
  • 7
  • 33
  • 52
0
votes
2 answers

Java Runtime exec: Get information from Firefox

With Java I am able to open Firefox just fine with a URL I set using this code: Runtime.getRuntime().exec("C:\\Program Files\\Mozilla Firefox\\firefox.exe" + " " + "http://www.website.com"); But if possible how can I then return the following…
zeddex
  • 1,260
  • 5
  • 21
  • 38
0
votes
2 answers

Runtime.getRuntime().exec(command); With virtual hard drive not working?

I did below: subst A: "C\Desktop" Now from java code: String command= "java -jar A:\test.jar" Process process = Runtime.getRuntime().exec(command); The JVM seems to be hanged here and never executing this line. When i run through "java -jar…
yami
  • 871
  • 1
  • 9
  • 14
0
votes
3 answers

Runtime Exception While using AsyncTask

I am doing mutlithreading in my program with AsyncTask by calling a Method after 10 secs but instead having this Exception : 08-04 11:49:29.565: E/log_tag(885): Error converting result java.lang.RuntimeException: Can't create handler inside thread…
Name is Nilay
  • 2,743
  • 4
  • 35
  • 77
0
votes
2 answers

Running java program from another java program

I'm trying to run a Java program from another Java application. Here is my code: public class Main { public static int Exec() throws IOException { Process p = Runtime.getRuntime().exec("javac -d C:/Users/Dinara/Desktop/D/bin " +…
Dinara
  • 523
  • 1
  • 6
  • 9
0
votes
1 answer

Executed programs run through java seem to time out?

I have an IRC bot which accepts commands from users to host specific game servers. However, after about half an hour to an hour of having the server up, the server just freezes up. The server is ran using Java's runtime execute command. Is there a…
Ivan
  • 87
  • 1
  • 7