//Main function public static void main(String[] args){ getSystemProperty();
Hashtable hashKey; hashKey=new Hashtable(); //将系统信息的关键字和标题放到hashtable hashKey.put("java.home","Java安装目录"); hashKey.put("java.class.path","装载类的路径"); hashKey.put("java.specification.version","Java API 规范的版本"); hashKey.put("java.specification.vendor","Java API 规范的厂商"); hashKey.put("java.specification.name","Java API 规范的名称"); hashKey.put("java.version","Java API 实现的版本"); hashKey.put("java.vendor","Java API 实现的厂商"); hashKey.put("java.vendor.url","Java API 规范厂商的URL"); hashKey.put("java.vm.specification.version","Java虚拟机规范的版本"); hashKey.put("java.vm.specification.vendor","Java虚拟机规范的厂商"); hashKey.put("java.vm.specification.name","Java虚拟机规范的名称"); hashKey.put("java.vm.version","Java虚拟机实现的版本"); hashKey.put("java.vm.vendor","Java虚拟机实现的厂商"); hashKey.put("java.vm.name","Java虚拟机实现的名称"); hashKey.put("java.class.version","Java类文件格式的版本"); hashKey.put("os.name","主机操作系统的名称"); hashKey.put("os.arch","主机操作系统的体系结构"); hashKey.put("os.version","主机操作系统的版本"); hashKey.put("file.separator", "平台目录的分隔符"); hashKey.put("path.separator","平台路径的分隔符"); hashKey.put("line.separator","平台文本行的分隔符"); hashKey.put("user.name","当前用户的帐户名称"); hashKey.put("user.home","当前用户的根目录"); hashKey.put("user.dir","当前工作目录"); Enumeration enum; String propertyKey; enum=hashKey.keys(); while(enum.hasMoreElements()){ propertyKey=(String)enum.nextElement(); System.out.println((String)hashKey.get(propertyKey) +":"+_property.getProperty(propertyKey)); } } /** * 获得系统属性列表 * @return Properties */ static public Properties getSystemProperty(){ _property=System.getProperties(); return _property; } }
google了一个,呵呵public class GetProps { public static void main(String[] args) { String s; try {
s = System.getProperty("java.version", "not specified"); System.out.println(" The version of the JVM you are running is: " + s); } catch (Exception e) { System.err.println("Caught exception " + e.toString()); } } }
//提示下载没搞过,不知道以上是否可行
import java.util.Properties;
import java.util.Hashtable;
import java.util.Enumeration;public class Test{
//存放JVM获得的系统属性
static private Properties _property;
//Main function
public static void main(String[] args){
getSystemProperty();
Hashtable hashKey;
hashKey=new Hashtable();
//将系统信息的关键字和标题放到hashtable
hashKey.put("java.home","Java安装目录");
hashKey.put("java.class.path","装载类的路径");
hashKey.put("java.specification.version","Java API 规范的版本");
hashKey.put("java.specification.vendor","Java API 规范的厂商");
hashKey.put("java.specification.name","Java API 规范的名称");
hashKey.put("java.version","Java API 实现的版本");
hashKey.put("java.vendor","Java API 实现的厂商");
hashKey.put("java.vendor.url","Java API 规范厂商的URL");
hashKey.put("java.vm.specification.version","Java虚拟机规范的版本");
hashKey.put("java.vm.specification.vendor","Java虚拟机规范的厂商");
hashKey.put("java.vm.specification.name","Java虚拟机规范的名称");
hashKey.put("java.vm.version","Java虚拟机实现的版本");
hashKey.put("java.vm.vendor","Java虚拟机实现的厂商");
hashKey.put("java.vm.name","Java虚拟机实现的名称");
hashKey.put("java.class.version","Java类文件格式的版本");
hashKey.put("os.name","主机操作系统的名称");
hashKey.put("os.arch","主机操作系统的体系结构");
hashKey.put("os.version","主机操作系统的版本");
hashKey.put("file.separator", "平台目录的分隔符");
hashKey.put("path.separator","平台路径的分隔符");
hashKey.put("line.separator","平台文本行的分隔符");
hashKey.put("user.name","当前用户的帐户名称");
hashKey.put("user.home","当前用户的根目录");
hashKey.put("user.dir","当前工作目录");
Enumeration enum;
String propertyKey;
enum=hashKey.keys();
while(enum.hasMoreElements()){
propertyKey=(String)enum.nextElement(); System.out.println((String)hashKey.get(propertyKey)
+":"+_property.getProperty(propertyKey));
}
}
/**
* 获得系统属性列表
* @return Properties
*/
static public Properties getSystemProperty(){
_property=System.getProperties();
return _property;
}
}
String s;
try {
s = System.getProperty("java.version", "not specified");
System.out.println(" The version of the JVM you are running is: " + s);
} catch (Exception e) {
System.err.println("Caught exception " + e.toString());
}
}
}
如:
try{
Class clazz = StringBuilder.class;
}catch(Exception e){
//JRE1.5以下版本
}
name="preview" id="preview"
codebase="<%=pluginURL.toString()%>"
width="100%" height="100%">
..........
</object>其中关键就是pluginURL的值,例如:
http://yourhost:yourport/yourpath/j2re-1_4_2_08-windows-i586-p.exe#Version=1,4,2,08将上面的Version后边的值改为你的目标JRE就可以了。
这样,如果Client机JRE版本低于这个版,就会到...exe去自动下载及安装,如果高于或等于则不会。