java:通过代码得到服务器和操作系统信息
2011-09-27 17:07
531 查看
In this example we are learn how we can get information about our operation system.
![](http://www.roseindia.net/images/previous.gif)
![](http://www.roseindia.net/images/bt_home.gif)
![](http://www.roseindia.net/images/next.gif)
In this example we are learn how we can get information about our operation system. In this example we are getting the OS name, its version and architecture of OS. We are using
getProperty(String key) to get the property of the OS. To get OS name we have key value
os.name,to get version we have os.version and to get architecture we have
os.orch.
The System class contains several useful class fields and methods. It cannot be instantiated.
The method and its keys:
String getProperty(String key):
This method is used to get the system property.
The code of the program is given below:
The output of the program is given below:
Operating System Information
![](http://www.roseindia.net/images/previous.gif)
![](http://www.roseindia.net/images/bt_home.gif)
![](http://www.roseindia.net/images/next.gif)
In this example we are learn how we can get information about our operation system. In this example we are getting the OS name, its version and architecture of OS. We are using
getProperty(String key) to get the property of the OS. To get OS name we have key value
os.name,to get version we have os.version and to get architecture we have
os.orch.
The System class contains several useful class fields and methods. It cannot be instantiated.
The method and its keys:
String getProperty(String key):
This method is used to get the system property.
S/No. | Key | Description |
1 | java.version | The version of Java Runtime Environment. |
2 | java.vendor | The name of Java Runtime Environment vendor |
3 | java.vendor.url | The URL of Java vendor |
4 | java.home | The directory of Java installation |
5 | java.vm.specification.version | The specification version of Java Virtual Machine |
6 | java.vm.specification.vendor | The name of specification vendor of Java Virtual Machine |
7 | java.vm.specification.name | Java Virtual Machine specification name |
8 | java.vm.version | JVM implementation version |
9 | java.vm.vendor | JVM implementation vendor |
10 | java.vm.name | JVM implementation name |
11 | java.specification.version | The name of specification version Java Runtime Environment |
12 | java.specification.vendor | JRE specification vendor |
13 | java.specification.name | JREspecification name |
14 | java.class.version | Java class format version number |
15 | ava.class.path | Path of java class |
16 | java.library.path | List of paths to search when loading libraries |
17 | java.io.tmpdir | The path of temp file |
18 | java.compiler | The Name of JIT compiler to use |
19 | java.ext.dirs | The path of extension directory or directories |
20 | os.name | The name of OS name |
21 | os.arch | The OS architecture |
22 | os.version | The version of OS |
23 | file.separator | The File separator |
24 | path.separator | The path separator |
25 | line.separator | The line separator |
26 | user.name | The name of account name user |
27 | user.home | The home directory of user |
28 | user.dir | The current working directory of the user |
public class OpertingSystemInfo { public static void main(String[] args) { String nameOS = "os.name"; String versionOS = "os.version"; String architectureOS = "os.arch"; System.out.println("\n The information about OS"); System.out.println("\nName of the OS: " + System.getProperty(nameOS)); System.out.println("Version of the OS: " + System.getProperty(versionOS)); System.out.println("Architecture of THe OS: " + System.getProperty(architectureOS)); } } |
C:\convert\rajesh\completed>javac OpertingSystemInfo.java C:\convert\rajesh\completed>java OpertingSystemInfo The information about OS Name of the OS: Windows 2000 Version of the OS: 5.0 Architecture of The OS: x86 |
相关文章推荐
- 各类Java heap space 解决方法,并通过java代码获取JVM的相关信息,所在操作系统的信息(包含eclipse&myeclipse的调试的内存设置)
- 通过JAVA代码获取手机的一些基本信息(本机号码,SDK版本,系统版本,手机型号)
- 不通用版(从SVN取版本,通过MAVEN生成JAVA包,通过SALTSTACK传送到远程服务器并自动重启TOMCAT服务)PYTHON代码
- 通过Java代码获取Zookeeper服务器状态
- java (服务器)代码读取apk信息
- 服务器通过模板发送邮件java代码
- 意外作出了一个javascript的服务器,可以通过js调用并执行任何java(包括 所有java 内核基本库)及C#类库,并最终由 C# 执行你提交的javascript代码! 不敢藏私,特与大家分
- 通过出生年月得到当前年龄java代码实例
- java得到类信息的代码演示
- Java反射之通过反射获取一个对象的方法信息(实例代码)
- 查询jvm参数以及操作系统信息的java代码
- 使用JAVA代码通过SSH访问远程windows,获取磁盘信息
- c++代码通过JNI调用Java代码时用到的签名信息如何获取
- java通过JVM获取操作系统信息
- 使用Java代码获取服务器性能信息及局域网内主机名
- java SDK ,上传、读取 基本类型数据通过服务器(客户端代码)
- EXECL导入(检查服务器版本.包括NPOI方式导入.可以通过配置文件信息导入EXECL)代码记录下.
- java代码通过ssh免密操作远程服务器shell
- 通过JAVA代码获取手机的一些基本信息(本机号码,SDK版本,系统版本,手机型号)
- Android-通过网络获取xml文件使用pull解析得到服务器中的信息(新闻客户端)