Additionally to words of fishtoprecords,if you want to use built-in commands from the OSes like DOS,Shell etc and to run them from Java,so you can do a platform independent if you check on which OS the program is running,so for checking create class constants:
/**
* some handy constants that can be used throughout the program
*/
public class Constants {
/**
* the name of the OS as given by the Java system property "os.name"
*/
public final static String osname = System.getProperty("os.name");
/**
* true if the program is running on OS X
*/
public final static boolean isOSX = osname.equalsIgnoreCase("Mac OS X");
/**
* true if the program is running on Linux
*/
public final static boolean isLinux = osname.equalsIgnoreCase("Linux");
/**
* true if the program is running on Solaris
*/
public final static boolean isSolaris = osname.equalsIgnoreCase("SunOS");
/**
* true if the program is running on Windows Vista
*/
public final static boolean isVista = osname.equalsIgnoreCase("Windows Vista");
/**
* true if the program is running on Windows
*/
public final static boolean isWindows = !(isOSX || isLinux || isSolaris);
}
And then you can in another class to execute command line commands checking which os is that and then to put the proper command of course in order not to be given different answers from the system