|
What this is
Other links
The source code
/*
* $Header: /cvsroot/mvnforum/myvietnam/src/net/myvietnam/mvncore/info/SystemInfo.java,v 1.7 2005/01/18 12:16:42 minhnn Exp $
* $Author: minhnn $
* $Revision: 1.7 $
* $Date: 2005/01/18 12:16:42 $
*
* ====================================================================
*
* Copyright (C) 2002-2005 by MyVietnam.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* All copyright notices regarding MyVietnam and MyVietnam CoreLib
* MUST remain intact in the scripts and source code.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Correspondence and Marketing Questions can be sent to:
* info@MyVietnam.net
*
* @author: Minh Nguyen minhnn@MyVietnam.net
* @author: Mai Nguyen mai.nh@MyVietnam.net
*/
package net.myvietnam.mvncore.info;
public class SystemInfo {
private String vmName;
private String vmVendor;
private String vmVersion;
private String runtimeName;
private String runtimeVersion;
private String osName;
private String osVersion;
private String cpu;
long totalMemory = 0;
long freeMemory = 0;
long totalMemoryKB = 0;
long freeMemoryKB = 0;
public SystemInfo() {
vmName = getProperty("java.vm.name");
vmVendor = getProperty("java.vm.vendor");
vmVersion = getProperty("java.vm.version");
runtimeName = getProperty("java.runtime.name");
runtimeVersion = getProperty("java.runtime.version");
osName = getProperty("os.name");
osVersion = getProperty("os.version");
cpu = getProperty("sun.cpu.isalist");
Runtime runtime = Runtime.getRuntime();
totalMemory = runtime.totalMemory();
freeMemory = runtime.freeMemory();
totalMemoryKB = totalMemory/1024;
freeMemoryKB = freeMemory/1024;
}
public static String getProperty(String key) {
String retValue = null;
try {
retValue = System.getProperty(key, "");
} catch (Exception ex) {
retValue = "no access";
}
return retValue;
}
public String getCpu() {
return cpu;
}
public String getOsName() {
return osName;
}
public String getOsVersion() {
return osVersion;
}
public String getRuntimeName() {
return runtimeName;
}
public String getRuntimeVersion() {
return runtimeVersion;
}
public String getVmName() {
return vmName;
}
public String getVmVendor() {
return vmVendor;
}
public String getVmVersion() {
return vmVersion;
}
public long getFreeMemory() {
return freeMemory;
}
public long getFreeMemoryKB() {
return freeMemoryKB;
}
public long getTotalMemory() {
return totalMemory;
}
public long getTotalMemoryKB() {
return totalMemoryKB;
}
}
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.