not able to execute the method based on OS in JAVA
HI,
I want to use same methods specific to OS but when I am trying to do so,I am only able to find out the OS name but it is not going inside that.I wrote a simple code as below --
Quote:
public class OSnane {
public static void main(String[] args) {
String OsName=null;
OsName=System.getProperty("os.name");
System.out.println("OS name="+OsName);
if(OsName == "SunOS")
System.out.println("hello Sun");
else if(OsName == "Windows XP")
System.out.println("Hello Windows");
else if(OsName == "Linux")
System.out.println("Hello Linux");
else
System.out.println("No OS selected!!!");
}
}
and Output is
Quote:
OS name=SunOS
No OS selected!!!
So how can I use the method based on the OS..
Thanks in advance....