?
Solved

Identify Operating System

Posted on 2011-10-12
7
Medium Priority
?
151 Views
Last Modified: 2012-05-12
Please let me know how I can figure out the Operating system (windows or mac) through java code.

Thanks!
0
Comment
Question by:dshrenik
  • 4
  • 3
7 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36958259
System.getProperty("os.name")
0
 

Author Comment

by:dshrenik
ID: 36958272
Is it possible to identify the family of OS?
I want to know if it windows / mac / linux. But I don't care which version.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36958285

String s = System.getProperty("os.name")
if(s.startsWith("Windows")) - this is windows,
but you should run some tests whaat weach system returns
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 36958288
you can look here ofr example of dioing something like that
http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/
0
 

Author Comment

by:dshrenik
ID: 36958295
But is there a generic way to figure out the family.
Like in ant, I can do this:

  <condition property="avn" value="avn.bat">
    <os family="windows"/>
  </condition>
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36958327
I am not sure there is a generic way - and how could it be - someone can come up with some new system
which will do something new

the tests in http://www.mkyong.com/java/how-to-detect-os-in-java-systemgetpropertyosname/
should cover most of the cases, but not guaranteed of faling
0
 

Author Comment

by:dshrenik
ID: 36958333
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question