This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Runtime.exec() question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Runtime.exec() question" Watch "Runtime.exec() question" New topic
Author

Runtime.exec() question

Cuneyt Taskiran
Greenhorn

Joined: Sep 18, 2008
Posts: 11
Hi,
I am trying to run the VideoLAN media player from withing my program using:

When this runs, VLC gives me an error for the second argument (the sout one). However, when I copy and paste the same command to the command line it works well. What am I missing? Should I escape singe quotes?

Thanks for the help,

C
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32689
    
    4
Don't know. But nobody should even think of going near Runtime.exec() without reading the classic paper by Michael Daconta. Google for "when Runtime.exec() won't".
Using a destroy() method looks suspect, even though that destroy() method isn't deprecated.
The ProcessBuilder class may make it easier to run a Process.
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

When using Runtime.exec() (or ProcessBuilder) you do not need to add any extra quoting to the command line arguments, like the single quotes in the --sout line. Try taking them out, then read Michael Daconta's paper.
Cuneyt Taskiran
Greenhorn

Joined: Sep 18, 2008
Posts: 11
QUESTION CLOSED
Getting rid of the single quotes in the --sout part of the command solved the problem.

I agree that destroy() is not an elegant way to terminate the process, will look into ProcessBuilder.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Runtime.exec() question
 
Similar Threads
help with running dos commands using java
How to connect to an UNIX server from Java application
Problem in unzipping a folder using java.util.zip API
Wireshark connectivity using java and string compare from text file
how to retrieve the value of ps - A command