Eghh! Gomer Pile trying to figure out Runtime.exec();

C

Chris

All, I am having the hardest time trying to understand documentation
regarding Runtime.exec(); That is, I am writing a java app that needs
to make a call to another app via windows command prompt. The problem
I am having is I cant figure out how to open the correct directory and
then execute the command call (because of quotes in the argument of
the command call. See below).

The directory is located in: C:\Program Files\BLAST\BIOINFORMATICS
\apildoc

And the command (w/associated arguments) is: BIOCommand\text="Hello,
Bio Entry1: HT8867" /peptides="Sc12.92"

Does anyone have expertise in this area that could help me? Thank you
very much for your time.




import java.io.IOException;

public class CmdPrompt {
public static void main(String args[])
{
try {
String command = new String[]{"cd", "\"c:\\Program Files\
\BLAST\\BIOINFORMATICS\", "BIOCommand\text="Hello, Bio Entry1:
HT8867" /peptides="Sc12.92""};
Runtime.exec(command);
}

catch (IOException e)
{
}
}
}
 
J

Joshua Cranmer

Chris said:
All, I am having the hardest time trying to understand documentation
regarding Runtime.exec(); That is, I am writing a java app that needs
to make a call to another app via windows command prompt. The problem
I am having is I cant figure out how to open the correct directory and
then execute the command call (because of quotes in the argument of
the command call. See below).

See said:
String command = new String[]{"cd", "\"c:\\Program Files\
\BLAST\\BIOINFORMATICS\", "BIOCommand\text="Hello, Bio Entry1:
HT8867" /peptides="Sc12.92""};
Runtime.exec(command);

Watch the 80-character width there!

Anyways, the most important thing to know is that Runtime != bash or DOS
or Command Prompt or whatever shell of your choice.
 
G

Gordon Beaton

All, I am having the hardest time trying to understand documentation
regarding Runtime.exec(); That is, I am writing a java app that
needs to make a call to another app via windows command prompt. The
problem I am having is I cant figure out how to open the correct
directory and then execute the command call

Runtime.exec() executes one command, not a sequence of them.

If you want the program to run in a specific directory, then use the
version of Runtime.exec() that lets you specify a directory (but not
as part of the command itself).

/gordon

--
 
M

Mark Space

Chris said:
try {
String command = new String[]{"cd", "\"c:\\Program Files\
\BLAST\\BIOINFORMATICS\", "BIOCommand\text="Hello, Bio Entry1:
HT8867" /peptides="Sc12.92""};
Runtime.exec(command);

I'm off to read the docs now, but normally you have to read the output
of the process you run, or it'll wedge (stop). You have to drain the
process's output stream, even if you don't do anything with the output.

I'll see if reading the docs refreshes any other ideas in my head....
 
L

Lew

Chris said:
        String command = new String[]{"cd", "\"c:\\Program  Files\
\BLAST\\BIOINFORMATICS\", "BIOCommand\text="Hello, Bio Entry1:
HT8867" /peptides="Sc12.92""};
   Runtime.exec(command);

Joshua said:
Watch the 80-character width there!

Also, watch out for the illegal statement there, too. Near as I can
tell without trying to compile it myself, that assignment to 'command'
will not compile, even after deleting the Usenet word-wrap artifacts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top