Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to find the OS (Windows or Unix)?

843798Sep 16 2003 — edited Nov 10 2003

In Java, is there any programmatic way of finding if an OS is Windows or Unix? I know of the following method:

String osName = System.getProperty( "os.name" );

But using this, a check will be needed for the hard coded substring "Windows", which is not an elegant solution.

Is there any other way of achieving this functionality?

Thanks!

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2003
Added on Sep 16 2003
3 comments
278 views