Runtime.exec() on Linux with spaces in arguments

Java 1.4.2

I have an application that needs to launch a PDF Viewer on linux to view a file. It's fine if there are no spaces in the filename, I just do:

Runtime.getRuntime().exec("xpdf -filename-")

and it all opens just fine. However, if the filename contains spaces, there doesn't seem to be any way to get it to work. I tried:

exec("xpdf -file name-")

but xpdf responds with, "Error: Couldn't open file '-file'", i.e. the filename up to the space.

So, I tried the other form of exec:

exec("xpdf",new String[]{"-file name-"})

Which gets me: "Error: Can't open display: "

If I put quotes around the filename they seem to be interpreted as part of the filename e.g. Error: Couldn't open file '"-filename'

What the heck do I do here?

[992 byte] By [i.am.noaha] at [2007-10-3 3:30:11]
# 1
String fileName = ...Runtime.getRuntime().exec(new String[] {"xpdf",fileName});
IanSchneidera at 2007-7-14 21:24:02 > top of Java-index,Java Essentials,Java Programming...