要求能检测几乎所有的版本,应该如何检测阿

解决方案 »

  1.   

    public static void main(String[] args) {
            System.out.print(System.getProperty("java.version"));
        }
      

  2.   

    System.out.print(System.getProperty("java.vm.version"));
      

  3.   

    就是打开一个网页,然后可以检测到客户端的jvm版本厂商哈
      

  4.   

    用一个applet到浏览器那边去执行
      

  5.   

    楼主说的检测客户端的java虚拟机的是java程序吧
    java程序运行应该都需要JVM吧...??如果没有JVM,这个检测的程序如何执行?也就是说,只有可能返回版本,怎么可能返回:"无"???
      

  6.   

    以下内容为JDK DOCS里JAVA WEB START章节,它给出了在浏览器里使用脚本语言判断javaws版本的实现代码。虽然和你要求检查JRE的初衷有所背离,不过你可以参考一下,况且,有JAVAWS必有JRE。
    http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/launch.html
    -----------------------------------------------------------------------------
    Detecting if Java Web Start is installed on Netscape
    Here is the first script that should be run on a web page for launching an application via JNLP:<SCRIPT LANGUAGE="JavaScript"> var javawsInstalled = 0;  
    var javaws142Installed=0;var javaws150Installed=0;isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) {    x = navigator.mimeTypes['application/x-java-jnlp-file'];    if (x) { 
          javawsInstalled = 1;       javaws142Installed=1;
          javaws150Installed=1;   } } else {    isIE = "true"; } </SCRIPT> 
    This script looks at the navigator.mimeTypes object and the navigator.mimeTypes.length var to decide if the browser is Netscape or IE. If length is 0, it is assumed the browser is IE, as with IE the navigator.mimeTypes array is defined but always empty. If length is non-zero, then the browser is assumed to be Netscape and the JNLP MIME type is checked to see if it exists on Netscape. If so, javawsInstalled, javaws142Installed, and javaws150Installed are all set to 1. With Netscape it is not possible to determine which particular version of Java Web Start is installed, so all four variables are set to 1.Detecting if JavaWeb Start is installed on IE, and if so, the version
    The above JavaScript should be followed by a VBScript that sets variables related to Internet Explorer browers: <SCRIPT LANGUAGE="VBScript">
    on error resume next
    If isIE = "true" Then
      If Not(IsObject(CreateObject("JavaWebStart.isInstalled"))) Then
         javawsInstalled = 0
      Else
         javawsInstalled = 1
      End If
      If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.4.2.0"))) Then
         javaws142Installed = 0
      Else
         javaws142Installed = 1
      End If 
      If Not(IsObject(CreateObject("JavaWebStart.isInstalled.1.5.0.0"))) Then
         javaws150Installed = 0
      Else
         javaws150Installed = 1
      End If  
    End If
    </SCRIPT>This VBScript is executed if the variable isIE from the preceeding JavaScript is "true"; i.e., if the end-user's browser is Internet Explorer. This script instantiates the isInstalled COM object in JavaWebStart.dll, and this object determines four things
      

  7.   

    最后一种方法应该可以 ,呵呵.不过太麻烦,因为jvm版本太多了