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

Accessing files from a Java Applet

I'm building this desktop application in java that reads input from Standard.in (or more specifically FileInputStream), I want to (or I am planning to) make it into a JApplet. I'm not an expert when it comes to web-programming, so the question is,…
user1508893
  • 9,223
  • 14
  • 45
  • 57
0
votes
4 answers

Execute ls star with Runtime.getRuntime() on Linux

I wanto to execute Runtime.getRuntime().exec(); on Java to list files on some directory. So I wanto to pass this command "ls /mnt/drbd7/i* | tail -1", but because the star the command returns null. And I realy need this star. I need to select the…
Felipe
  • 7,013
  • 8
  • 44
  • 102
0
votes
1 answer

How to wait for a batch file processing to end which is executed using Runtime.exec or ProcessBuilder.start, before moving to the next statement?

I have written a small application for a project..that will do following tasks: Writes a commands.bat file. This bat file has some source-code-server commands that will take sometime to get process. Executes the commands.bat using ProcessBuilder…
Peeyush
  • 33
  • 1
  • 9
0
votes
2 answers

how to reproduce java.io.IOException exception for Runtime.exec()?

At times, I get "java.io.IOException: error=12, Cannot allocate memory" in my java application. I want to reproduce it on my machine. Is there a way to reproduce this error? When will Runtime.exec throw java.io.IOException? FYI, [root@ara ~]# java…
0
votes
1 answer

How to run sudo command without rewriting sudo with Runtime.getRuntime().exec()

Is it possible to make a terminal in java where a user can make a sudo command without rewriting sudo as gksudo or doing anything else like in a basic terminal. I don't want to rewrite the command because I don't like to change the command a user…
Coding Guy
  • 95
  • 1
  • 7
0
votes
1 answer

Exec multiple shell command with onClick

here is an example of what i'm trying to make: final String[] hwdebug1 = {"su","-c","echo hello > /system/hello1.txt"}; try { Runtime.getRuntime().exec(hwdebug1); } catch…
iGio90
  • 290
  • 1
  • 4
  • 15
0
votes
2 answers

Executing a net use command

I need to execute a net use command which is written in a batch file to enable a drive. Batch file is as follows: net use * /delete /Y net use l: \\ /user:\ The above batch file enables a drive for…
0
votes
0 answers

Calling .exe file but stdInput.readline gives same output for every input

I am calling external myexefile.exe from java. The .exe File is executed properly in java but when I captured output of the .exe file through the following code, for each input every time it gives the same output 55.11 .However in command prompt…
0
votes
2 answers

How to open a terminal window and execute a customer program in java

I want to open a new terminal window and execute my program in java code. So I use: Runtime.getRuntime().exec("gnome-terminal -x /path/to/my/program arg1 arg2"); This is work fine in Ubuntu but unfortunately it is not work in CentOS, the problem…
Kery
  • 513
  • 8
  • 22
0
votes
2 answers

Console Commands Minecraft Server Start/Stop Through Java GUI

I can't for the life of me figure out how to start a nd stop a server for the game Minecraft using two buttons in Java. So far I have this mess.. try { ProcessBuilder processBuilder = new…
Brilliance Of Ben
  • 91
  • 1
  • 3
  • 11
0
votes
2 answers

Running mysqldump from java in linux

** The following command works fine when run directly on terminal mysqldump -uabc -pabc1234 --compact --no-create-info -w \"fieldname != 'A'\" dbname tablename -hhostaddress --result-file=/tmp/myfile.txt ** But when it is executed using Runtime()…
richa.a91
  • 11
  • 1
  • 8
0
votes
1 answer

A blocked external process in a swing GUI

I am developing an encoder with java swing and ffmpeg. I created a GUI interface in which I specify my inputs (devices, frame rate, bitrate..). Then I call ffmpeg to encode and stream. My problem is that the encoding class is well executed from a…
0
votes
1 answer

I just write a wrapcommand in java but sometimes it do not print the command output. WHY

I just write a simple commandwrapper in java, this is construction function: Process process; Thread in; Thread out; public CommandWrapper(Process process) { this.process = process; final InputStream inputStream =…
user504909
  • 9,119
  • 12
  • 60
  • 109
0
votes
2 answers

Running txt files in different editors by just writing programms name

i got two questions. Where is the directory the Method Runtime.getRuntime().exec() gets its resources from? if i am calling Runtime.getRuntime().exec("notepad.exe"), why does it start the windows editor? Where does java gets the .exe source from?…
SomeJavaGuy
  • 7,307
  • 2
  • 21
  • 33
0
votes
0 answers

Error when trying to run cvs through Runtime.exec()

I usually use WinCVS, but I'm trying to write a Java app to automate some of the build/deployment tasks. If I run cvs -n update from the command line, I get the results of the query. If I run it via Runtime.exec() I get the below error. Any ideas?…
phil-daniels
  • 574
  • 2
  • 10
  • 28