Detecting what OS the application is running on ?

Hello.Can anyone please let me know of a way that i could detect on what OS is my application running on. For example if i'm running on MAC, WIndows or Linux ....
[184 byte] By [geotdw] at [2007-9-26 1:14:14]
# 1
System.getProperty( "os.name" ); see the javadoc of System.getProperties() for a complete list of properties any JVM should define.
remu at 2007-6-29 0:31:09 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2
What i need to say is, check what OS i'm running on. If i'm running on windows set the Look & Feel to windows, if MAC then MAC and so on ? If i use System.getProperty("Os.Name") then i have to specify the OS's name which i don't want to do...
geotdw at 2007-6-29 0:31:09 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3

> What i need to say is, check what OS i'm running on.

> If i'm running on windows set the Look & Feel to

> windows, if MAC then MAC and so on ? If i use

> System.getProperty("Os.Name") then i have to specify

> the OS's name which i don't want to do...

I said getProperty not setProperty, with a g .... and the property name is case sensitif, so stick to "os.name", not "Os.Name".

Anyway, If you need this info for the LookAndFeel (info that was not present in your first post) then you should rather have a look at javax.swing.UIManager.getSystemLookAndFeelClassName()

remu at 2007-6-29 0:31:09 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 4

If you want to set the L&F to match the L&F of the operating system your program is running on, then you don't need to find out what the operating system is at all, you need this:

try {

UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

} catch (Exception e) {}

DrClap at 2007-6-29 0:31:09 > top of Java-index,Archived Forums,New To Java Technology Archive...