Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime.exec() question

 
Cuneyt Taskiran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 48932
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic