• Post Reply Bookmark Topic Watch Topic
  • New Topic

Determine windows, unix or other OS?

 
rashidi ahad
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can java programmed to detect what os is running on the remote host?..

if cannot, is there any other ways to detect the OS?.


thanks
 
Mark Smith
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can detect which os is running by using the following code:

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

It will return something like "Windows 2000".

You can get all the properties by running the following code:

Properties props = System.getProperties();

// Enumerate all system properties
Enumeration enum = props.propertyNames();
for (; enum.hasMoreElements() ;) {
// Get property name
String propName = (String) enum.nextElement();

// Get property value
String propValue = (String) props.get(propName);
System.out.println(propName + " - " + propValue);
}
[ June 30, 2005: Message edited by: Richard Nienaber ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!