您的位置:首页 > 其它

判断是32位还是64位的CPU,CPU型号

2013-06-03 16:15 197 查看
多少位:

查看OS核心是32位还是64位
SOLARIS:
#isalist-v
#isainfo-v
#isainfo-b

AIX:

bootinfo-K

#bootinfo-k

显示AIX系统内核是32位还是64

#bootinfo-y
显示机器硬件是32位还是64位

#bootinfo-p
显示机器是否支持64位内核(32:32位;chrp:64位)

用man看看bootinfo的参数,就知道得更详细了

#prtconf-k

要显示CPU类型,例如是32位还是64位

#prtconf-c

HP-UX
getconfKERNEL_BITS

==============================================================

CPU型号:

Youcangetthe
os.arch
property:

StringosArch=System.getProperty("os.arch");

thiswilltellyouthearchitectureoftheOS,sonotexactlytheoneoftheVM.

Sun'sJREshavethefollowingproperties(valuesfrommymachine)thatmaybeuseful:

sun.arch.data.model:32
sun.cpu.isalist:pentium_pro+mmxpentium_propentium+mmxpentiumi486i386i86

ButhaveinmindthatthesewillnotworkonVMsfromothervendors.SoyoumaywanttofindsuchpropertiesofotherVMsaswell,sothatyouarenotvendor-dependent.

publicclassOpertingSystemInfo
{
publicstaticvoidmain(String[]args)
{
StringnameOS="os.name";
StringversionOS="os.version";
StringarchitectureOS="os.arch";
System.out.println("\nTheinformationaboutOS");
System.out.println("\nNameoftheOS:"+
System.getProperty(nameOS));
System.out.println("VersionoftheOS:"+
System.getProperty(versionOS));
System.out.println("ArchitectureofTHeOS:"+
System.getProperty(architectureOS));
}
}


Theoutputoftheprogramisgivenbelow:

C:\convert\rajesh\completed>javacOpertingSystemInfo.java

C:\convert\rajesh\completed>javaOpertingSystemInfo

TheinformationaboutOS

NameoftheOS:Windows2000
VersionoftheOS:5.0
ArchitectureofTheOS:x86

UNIX命令查看32/64位:

file/bin/ls


Enterjava-versiononthecommandline.Ifit's64-bitsitwillsayso,otherwiseit's32-bits.

E.g.

64bitsOracle/MacOSX

$java-version

javaversion"1.6.0_20"Java(TM)SERuntimeEnvironment(build1.6.0_20-b02-279-10M3065)JavaHotSpot(TM)64-BitServerVM(build16.3-b01-279,mixedmode)

32bitsOracle/MacOSX(client)

$java-version

javaversion"1.6.0_20"Java(TM)SERuntimeEnvironment(build1.6.0_20-b02-279-10M3065)JavaHotSpot(TM)ClientVM(build16.3-b01-279,mixedmode,sharing)

32bitsOracle/MacOSX(server)

$java-server-version

javaversion"1.6.0_20"Java(TM)SERuntimeEnvironment(build1.6.0_20-b02-279-10M3065)JavaHotSpot(TM)ServerVM(build16.3-b01-279,mixedmode)

64bitsOpenJDKUbuntu

$java-version

javaversion"1.6.0_20"OpenJDKRuntimeEnvironment(IcedTea61.9.1)(6b20-1.9.1-1ubuntu3)OpenJDK64-BitServerVM(build17.0-b16,mixedmode)

32bitsSoylatteMacOSX

$java-version

javaversion"1.6.0_03-p3"Java(TM)SERuntimeEnvironment(build1.6.0_03-p3-landonf_19_aug_2008_14_55-b00)JavaHotSpot(TM)ClientVM(build1.6.0_03-p3-landonf_19_aug_2008_14_55-b00,mixedmode)

32bitsOpenJDKMacOSX

$java-version

openjdkversion"1.6.0-internal"OpenJDKRuntimeEnvironment(build1.6.0-internal-landonf_17_may_2009_13_58-b00)OpenJDKClientVM(build11.0-b17,mixedmode)

64bitsIBMLinux

$java-version

javaversion"1.6.0"Java(TM)SERuntimeEnvironment(buildpxa6460sr8fp1-20100624_01(SR8FP1))
IBMJ9VM(build2.4,JRE1.6.0IBMJ92.4Linuxamd64-64jvmxa6460sr8ifx-20100609

*************************************************************************************************************
java获取Mac地址:
java通过ProcessBuilder执行本地shell命令获取ip配置信息[/code]

[java]代码库
viewsourceprint?
importjava.io.File;
importjava.io.IOException;
importjava.io.InputStream;
importjava.util.Map;

/**
*通过ProcessBuilder执行本地命令。此类用于创建操作系统进程。获取本机的ip配置信息
*
*每个进程生成器管理这些进程属性:(1)命令是一个字符串列表,它表示要调用的外部程序文件及其参数(如果有)(2)环境是从变量到值
*的依赖于系统的映射。初始值是当前进程环境的一个副本.(3)工作目录。默认值是当前进程的当前工作目录,通常根据系统属性user.dir来命名.
*(4)redirectErrorStream属性。最初,此属性为false,意思是子进程的标准输出和错误输出被发送给两个独立的流,这些流可以通过
*Process.getInputStream()和Process.getErrorStream()方法来访问。如果将值设置为
*true,标准错误将与标准输出合并。这使得关联错误消息和相应的输出变得更容易。在此情况下,合并的数据可从
*Process.getInputStream()返回的流读取,而从Process.getErrorStream()返回的流读取将直接到达文件尾。
*/
publicclassUsingProcessBuilder{

/**
*获取Windows系统下的网卡的MAC地址
*
*@return
*/
publicstaticStringgetPhysicalAddress(){
Processp=null;

try{
//执行ipconfig/all命令
p=newProcessBuilder("ipconfig","/all").start();
       //非window平台
       p=newProcessBuilder("ifconfig","-a").start();
}catch(IOExceptione){
return"";
}
byte[]b=newbyte[1024];
intreadbytes=-1;
StringBuffersb=newStringBuffer();
//读取进程输出值
InputStreamin=p.getInputStream();
try{
while((readbytes=in.read(b))!=-1){
sb.append(newString(b,0,readbytes));
}

}catch(IOExceptione1){
}finally{
try{
in.close();
}catch(IOExceptione2){
}
}

returnsb.toString();
}

/**
*执行自定义的一个命令,该命令放在C:/temp下,并且需要2个环境变量的支持。
*/
publicstaticbooleanexecuteMyCommand(){
//创建系统进程创建器
ProcessBuilderpb=newProcessBuilder("myCommand","myArg1","myArg2");
//获得进程的环境
Map<String,String>env=pb.environment();
//设置和去除环境变量
env.put("VAR1","myValue");
env.remove("VAR0");
env.put("VAR2",env.get("VAR1")+";");
//切换工作目录
pb.directory(newFile("C:/temp"));
try{
//得到进程实例
Processp=pb.start();
//等待该进程执行完毕
if(p.waitFor()!=0){
//如果进程运行结果不为0,表示进程是错误退出的
//获得进程实例的错误输出
InputStreamerror=p.getErrorStream();
//dosomething
}
//获得进程实例的标准输出
InputStreamsdin=p.getInputStream();

}catch(IOExceptione){
}catch(InterruptedExceptione){
}
returntrue;
}

publicstaticvoidmain(String[]args){
Stringaddress=UsingProcessBuilder.getPhysicalAddress();

System.out.println(address);

}
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: