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

getRuntime.exec() is not working, ubuntu 13.04

The following command is working perfectly when I execute it from the terminal: rm -f /home/folkman/Desktop/DimacsProba/* However, I want to execute it with Java. I am using Netbeans and when I used an older version of Ubuntu, it worked: …
-1
votes
1 answer

Delaying Runtime.exec to give Apache POI time to write a file?

I have written a method that successfully exports data from an array to an Excel file. However, I would like Java to automatically open the freshly created Excel file when Apache POI is done writing it. My code looks like this: public void…
Aeronth
  • 804
  • 1
  • 6
  • 16
-1
votes
3 answers

How to choose a program to run?

I have this code: import javax.swing.JOptionPane; class OpenProgram { public static void main(String[] args) throws Exception { // opens the JOptionPane String path = JOptionPane .showInputDialog("Type the path…
livefree75
  • 720
  • 8
  • 18
-1
votes
2 answers

Button to open text file won't function with text file not in class root directory

I have this button which is meant to open a text file for easy tweaking. It works fine when I put the text file in the same directory, but when I try to put it in a subsidiary directory and change the path to "config/gameItems.txt" it doesn't do…
Peter F
  • 435
  • 1
  • 8
  • 17
-1
votes
3 answers

Runtime excecute command wont end

I am running this code: Runtime rt = Runtime.getRuntime(); rt.exec("explorer"); rt = null; The code runs and do the job, but the program dont terminate - that is the red light (using Eclipse IDE) is still on meaning the program didnt ended. What…
Michael A
  • 5,770
  • 16
  • 75
  • 127
-1
votes
4 answers

Running .bat from Java doesn't show the CMD

I'm trying to run a.bat file which is located here: C:\A\B\C\D E\F So I invoke: cmd /c "cd C:\A\B\C\D E\F && a.bat" on the CMD and I can see the execution of the file. Now I want to run this file from Java and then delete it, so I…
Maroun
  • 94,125
  • 30
  • 188
  • 241
-1
votes
2 answers

java exec() run a db2 import command, waitfor() never return

I used java process run a external command. This command is .bat file with some db2 commands. When I want use the process waiffor() return a result, I can't get anything. The program must be block. java code: ..... Runtime rt =…
saneryee
  • 3,239
  • 31
  • 22
-1
votes
4 answers

Run jar file from java application

Possible Duplicate: Run Java program into another Program i try to run jar file from java application which was created in eclipse. when i run jar file using below source code then fire Unable to access jarfile error Process process =…
user1508234
  • 7
  • 1
  • 5
-1
votes
2 answers

How to run cmd.exe with command string from Java?

Uff... tried to google but with no result. Hello everybody. I need to run via cmd.exe the next command from java programm (javascript syntax): "/c cd c:\prb && Processing.bat c:\prb ext.dat auto" it means i need to change current directory to…
May12
  • 2,420
  • 12
  • 63
  • 99
-2
votes
1 answer

Running a Linux Command through a Java GUI

I can get my terminal to show up but I can't get my code to run: and always get the exception. Any idea what's wrong? if (e.getActionCommand() == "Start") { String command= "/usr/bin/pg_ctl -D /var/lib/pgsql/data -l /var/lib/pgsql/log/pgsql.log …
-2
votes
3 answers

getRuntime().exec() return exit code 11

I am using Runtime.getRuntime().exec() method to run a command and I get exit code 11 when I call Process.waitFor(). When I run the same command on the console it runs as expected. the command is: hive -hiveconf…
zohar
  • 2,298
  • 13
  • 45
  • 75
-2
votes
1 answer

ProcessBuilder and RunTime.exec not running my in code

I'm coding one application for my mongodb server in java, and I need to: 1 - Start my Mongo DB server (in terminal it is: "mongod") 2 - Access the Mongo and drop one collection (executing in terminal: "mongo", "use my_db" and…
-2
votes
1 answer

Inconsistent behavior while executing batch file from java

Our java method executes a batch script as below: String command = batchFilePath + File.separator + filename + " " + path; logger.info("Command to be executed = " + command); Process process =…
AsteriK
  • 39
  • 1
  • 9
-2
votes
1 answer

convert java String to String[] using runtime.exec()

I have a method like public String doSomething(String paramString) { try { //do something with paramString and store it in myNewValue return new String(myNewValue, "UTF8"); } catch blocks... } Let's say…
qre0ct
  • 5,680
  • 10
  • 50
  • 86
-2
votes
1 answer

Why does exec() start a ADB daemon?

I am building an app for some set of rooted phones I have. I was wondering if there is any way that I could uninstall a system app which comes with the phone running some code from my app. I have tried running commands like adb shell pm clear…
sami
  • 49
  • 13
1 2 3
58
59