How to get platform type?
Guys,
I want to useRuntime.getRuntime().exec(cmd) to execute an external program. This program has multiple versions for different platform.
I understand that thecmd is different for different platforms, cmd for windows and sh for linux.So I want to determine the current platform. How to do that?
Or is there any other methods?
Thanks in advance!
[397 byte] By [
wateicea] at [2007-10-3 2:46:39]

Hi,
You could try
private final static String osName= System.getProperty( "os.name" );
then interogate this for "windows" etc
There may be better ways of doing it but this i think is about the simplist.
Hope it helps
you're immediately into approximation territory here - but if you really have to do this then a list of values from os.name and os.arch can be found here
http://www.vamphq.com/jnlpref.html#os-arch-codes
it might be enough to divide the world into windows and non-windows (unix), but many unix built-in commands have differing switches on different unix variants so you have to test everywhere
asjfa at 2007-7-14 20:35:25 >
