Opening or running OS commands in java

I would like to know how to make OS calls from within java. I'm programming for windows 9x/2000 and would like to be able to tell the OS to open certain files (with the associated program in windows' registry). I have achieved this with runtime exec and a string. For example, lets say I want to open a file "text.txt". I can execute the string "cmd /c text.txt" to open it. However, "cmd" doesn't work in win9x and "command.com" doesn't seem to work either.

Is there a more general way of telling the OS to open files than this? I might also want to make this program work on other platforms than windows, so I would need something more general.

Thanks !

[685 byte] By [fcharron] at [2007-9-26 2:37:54]
# 1
try to add 'start ' at the beginning of your command straing : start cmd ... or start command.com...you may also tryto launch a *.bat file, but hen you need to create it before (either manually or programmatically)good luckvincent
dupontv at 2007-6-29 10:07:58 > top of Java-index,Archived Forums,Java Programming...
# 2

hi,

there's a command Runtime

look at my code-example:

Runtime rt = Runtime.getRuntime();

try {

Process child = rt.exec("enter command here e.g. test.txt");

child.destroy();

}

catch(IOException e){

System.err.println("ERROR");

}

hope this helps

easy

mreasy at 2007-6-29 10:07:58 > top of Java-index,Archived Forums,Java Programming...