[Arakhnę-Dev] [98] Add utility class to display on standard output the operating system and the virtual machine informations .

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 98
Author:   galland
Date:     2009-12-01 09:07:01 +0100 (Tue, 01 Dec 2009)
Log Message:
-----------
Add utility class to display on standard output the operating system and the virtual machine informations.

Added Paths:
-----------
    trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/OperatingSystemInfo.java

Added: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/OperatingSystemInfo.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/OperatingSystemInfo.java	                        (rev 0)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/OperatingSystemInfo.java	2009-12-01 08:07:01 UTC (rev 98)
@@ -0,0 +1,79 @@
+/* 
+ * $Id$
+ * 
+ * Copyright (C) 2009 Stéphane GALLAND
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * This program is free software; you can redistribute it and/or modify
+ */
+
+package org.arakhne.vmutil;
+
+/**
+ * This class print on the standard output several informations
+ * about your operating system.
+ * These informations are extracted by the Java or the native
+ * libraries from <code>arakhneVmutils</code>.  
+ *
+ * @author St&eacute;phane GALLAND &lt;galland@xxxxxxxxxxx&gt;
+ * @version $Name$ $Revision$ $Date$
+ */
+public class OperatingSystemInfo {
+
+	private static void showTitle(String title) {
+		System.out.print("#######################################\n# "); //$NON-NLS-1$
+		System.out.println(title);
+		System.out.println("#######################################"); //$NON-NLS-1$
+	}
+	
+	private static void showPropertyValue(String name) {
+		showValue(name, System.getProperty(name));
+	}
+	
+	private static void showValue(String name, String value) {
+		System.out.print(name);
+		System.out.print(" = "); //$NON-NLS-1$
+		System.out.println(value);
+	}
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		
+		showTitle("JRE Properties"); //$NON-NLS-1$
+		
+		showPropertyValue("java.class.path"); //$NON-NLS-1$
+		showPropertyValue("java.library.path"); //$NON-NLS-1$
+		showPropertyValue("java.home"); //$NON-NLS-1$
+		showPropertyValue("os.name"); //$NON-NLS-1$
+		showPropertyValue("path.separator"); //$NON-NLS-1$
+		showPropertyValue("sun.arch.data.model"); //$NON-NLS-1$
+		showPropertyValue("user.dir"); //$NON-NLS-1$
+		showPropertyValue("user.name"); //$NON-NLS-1$
+		
+		showTitle("OperatingSystem"); //$NON-NLS-1$
+		
+		showValue("getCurrentOSName()", OperatingSystem.getCurrentOSName()); //$NON-NLS-1$
+		showValue("getCurrentOSVersion()", OperatingSystem.getCurrentOSVersion()); //$NON-NLS-1$
+		showValue("getOSSerialNumber()", OperatingSystem.getOSSerialNumber()); //$NON-NLS-1$
+		showValue("getOSUUID()", OperatingSystem.getOSUUID()); //$NON-NLS-1$
+		showValue("getOperatingSystemArchitectureDataModel()", Integer.toString(OperatingSystem.getOperatingSystemArchitectureDataModel())); //$NON-NLS-1$
+		showValue("getCurrentOS()", OperatingSystem.getCurrentOS().name()); //$NON-NLS-1$
+		showValue("is32BitOperatingSystem()", Boolean.toString(OperatingSystem.is32BitOperatingSystem())); //$NON-NLS-1$
+		showValue("is64BitOperatingSystem()", Boolean.toString(OperatingSystem.is64BitOperatingSystem())); //$NON-NLS-1$
+	}
+
+}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/