Runtime exec exception

I've been having this problem with Runtime.exec for a couple days and I have searched for solutions extensively but to no avail. It'd be great if anyone could tell me what went wrong:

Basically I'm trying to invoke an external process from the main application using the exec method of Runtime class. The process is a lexical/syntactic parser made by lex and yacc (it is supposed to parse a raw file and produce an xml file which will be fed to the main application). But there's always a run time exception the error message is as follows:

java.io.IOException: CreateProcess: .\prog calendars1.txt error=193

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.<init>(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at Parser.Application.executeRuntime(Application.java:39)

at Parser.Application.<init>(Application.java:12)

at Parser.Application.main(Application.java:62)

Would anyone give me some hints on this please? Thanks a advance!

By the way, the flatform is Unix.

[1283 byte] By [yid85a] at [2007-11-27 11:03:44]
# 1

Without more context, hard to tell.

How are you calling Runtime.exec?

dwga at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...
# 2

The method that executes the commands is as follows:

private BufferedReader executeRuntime(String command)

{

Runtime runtime = Runtime.getRuntime();

try

{

Process process = runtime.exec(command);

process.waitFor();

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

return bufferedReader;

}

catch(InterruptedException e)

{

System.out.println("The process has been interrupted");

System.exit(1);

}

catch(IOException e)

{

System.out.println("Runtime exception");

e.printStackTrace();

System.exit(1);

}

return null;

}

And to invoke an external process, I do

BufferedReader bufferedReader = executeRuntime("./prog calendars1.txt"), where ./prog is the compiled executable parser and calendars1.txt is the file to parse, and bufferedReader contains the output from this process.

I have tested the above code with executeRuntime("ls") and it works fine and there's also no problem with the executable parser. But the two things just cannot work out when put together. Any ideas?

yid85a at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...
# 3

Well according to your error message the String you're trying to execute is ".\prog calendars1.txt", but shouldn't it be "./prog calendars1.txt"?

dwga at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...
# 4

you are right, it was just a typo in my post; it was actually "./prog calendars1.txt" in the program but still gives run time exception.

yid85a at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...
# 5

When I googled "error 193" it gave me this link:

http://www.theserverside.com/discussions/thread.tss?thread_id=17795

DrClapa at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...
# 6

This is so weird, in the code i clearly put "./" and it automatically turned to ".\" ?! Sorry to confuse anyone, but I'm realy at the end of my tether and haven't got clue how to fix this up. Could anyone help please

yid85a at 2007-7-29 12:52:15 > top of Java-index,Java Essentials,Java Programming...