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

Applet executing program on server

I've got an applet, which has to exec a program on the same server. Runtime c = Runtime.getRuntime(); window.finishedQuery("Got Runtime..."); Process p = c.exec(String.format("cmd"); window.finishedQuery("Excecuted CMD"); 2nd line doesn't work in…
0
votes
2 answers

Can't launch .exe from Java

I am trying to launch a .exe file through a Java program. I used the following code: System.out.println("Opening " + path); Process exec; exec = Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + path);//path is the path of the exe…
salabh
  • 1
  • 2
0
votes
1 answer

Running external script from Java application on OS X

I'm having real issues getting an external script to run from my Java application on OS X 10.8. It works on Windows, so not sure what I'm doing wrong for OS X. What works (Windows): String[] commands = { "\"" + _appDataDir + "\\Temp\\Workers\\"…
aritchie
  • 601
  • 10
  • 18
0
votes
1 answer

Running a .bat inside Java Swing GUI Not Working

Using the following code, I can get the .bat file to execute (no GUI, just the following lines). However, when I add it in as a method of the ActionListener for the button (its a Java Swing app), the .bat file never executes. Any ideas? Runtime…
0
votes
1 answer

Java ProcessBuilder throwing IOException

Possible Duplicate: Outputting result of “dir” to console in Java I'm probably doing something silly here. Please help. Here's the simple code: new ProcessBuilder("dir").start(); Error message: java.io.IOException: Cannot run program "dir":…
Kes115
  • 2,070
  • 2
  • 21
  • 37
0
votes
3 answers

How to connect to server running on the system with password protection in java?

I am trying to use Runtime.exec to run a class file from my java code but not able to launch the new process on Linux,The same is working on the windows.. I want or launch the process from GUI (which I am running from a jar file named Launch.jar) on…
milan kumar
  • 226
  • 2
  • 16
0
votes
0 answers

Synchronicity of runtime.exec in Java

I have some code in which proc = Runtime.getRuntime().exec(cmd) is called to launch a subprocess, and then there is some communication between the parent and child processes. In some cases, I'm getting java.io.IOException: The pipe is being closed…
mfsiega
  • 2,852
  • 19
  • 22
0
votes
1 answer

Runtime.getRuntime().exec() in Java with file redirection

Possible Duplicate: Redirection with Runtime.getRuntime().exec() doesn’t work I'm trying to run a SQL script with Java on OS X to initiate my database for testing. I know it's not the preferred way to do it, but it's a temporary solution. I've…
Skovly
  • 234
  • 1
  • 8
  • 22
0
votes
1 answer

MyRuntime.exec() saying file not found

This is JAVA programming language question This is the code im trying to execute : MyRuntime = Runtime.getRuntime(); File temp = new File("C:\\Command Line Apps\\cURL\\"); for(String filenames : temp.list()) System.out.println(filenames); curl =…
anony Mus
  • 1
  • 1
0
votes
2 answers

Using Java to find Postgresql installation location

I want to find out the installation location of Postgresql and need to make some changes in postgresql.conf and pg_hba.conf files and restart Postgresql. Is there any way to identify the installation directory which can be applied to…
Lolly
  • 34,250
  • 42
  • 115
  • 150
0
votes
2 answers

Add space in adb command

I want to execute "adb" command using Java. I tried out as follow: Process p = Runtime.getRuntime().exec(new String[]{"cmd","/c","adb devices"}); But, I get following error p.getErrorStream(): 'adb' is not recognized as an internal or external…
Sachin J
  • 2,081
  • 12
  • 36
  • 50
0
votes
3 answers

How to programmatically answer a call in Android 4.0.3?

So as the subject states I need to be able to answer a phone call programmatically in Android 4.0.3 on an HTC OneX. I have read several places that the MODIFY_PHONE_STATE permission has been revoked by Google so to do this task you need a work…
onetwopunch
  • 3,279
  • 2
  • 29
  • 44
0
votes
1 answer

Change Android IP address using application

I am trying to change the ip address inside my application for emulator or a device This the code: try { Runtime.getRuntime().exec(new String[]{"su","-c","ifconfig eth0 xx.xx.xx.xx"}); } catch (IOException e) { e.printStackTrace(); } No…
user1426149
  • 43
  • 1
  • 4
0
votes
1 answer

run program in java read what it is doing

I want to run a program like a video game in java and have it output everything it does in java, is this possible? To clarify on everything, I want to see the output of the game in terms of what it is doing. I understand it may not come out…
jerhynsoen
  • 205
  • 1
  • 7
  • 20
0
votes
1 answer

SVN Info command different when run from Java than in terminal

I'm using the svn command from Java to get info about a working copy. final Process exec = Runtime.getRuntime().exec( new String[]{"svn","info","--xml","/path/to/wc"} ); ByteStreams.copy(exec.getErrorStream(), System.err); // ... more code to…
Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301