Hi,
In my application,I want to find out the OS name and based on OS I want to do some specific operations.So I write some code based on it in JAVA but I am able to get the OS name but Not able to use the method specific to OS.I write a simple code to check it and found that it is not going to the if statement.code is as follow--
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 the Output is:
Quote:
OS name=SunOS
No OS selected!!!
|
So please tell me how can I Use methods based on OS.
Thanks in Advance ...