Detect if Swing is installed
public class SwingSniffer extends java.applet.Applet {
  public void init() {  
    try {
      com.sun.java.swing.JButton dummy = 
          new com.sun.java.swing.JButton("foo");
      System.out.println("Swing is here"); 
      // getAppletContext().showDocument
      // (new URL(getCodeBase()+"AppletPageWithNoArchiveTag.html"));
      } 
    catch(Exception e) {
      System.out.println("Swing is not here, you must download or install it");    
      // getAppletContext().showDocument
      // (new URL(getCodeBase()+"AppletPageWithArchiveTag.html"));
      }
    } 
}
 <HTML><HEAD></HEAD><BODY>
<APPLET CODE="SwingSniffer.class"  
      HEIGHT=1 WIDTH=1>
 <A HREF="/nojava.html">
   Oups! You don't have JAVA enabled, click here.</A>        
</APPLET>
<A HRES="lan/jre.exe">install</A>
</BODY></HTML>

解决方案 »

  1.   

    to: mtou(逆风)
    找注册表的什么键啊to:wangyanqiu(*我要我的音乐*) 
    我要在安装程序里判断,你这个怎么弄呢?
      

  2.   

    查找环境变量,如果能取出%java_home%就说明装了
    顺便还可以知道版本:)
      

  3.   

    不对吧,我自己机器上装了JRE,并没有JAVA_HOME这个环境变量啊
      

  4.   

    晕,我机器的注册表是:
    hkey_users\S-1-5-21-842925246-1935655697-1708537768-1003\software\JavaSoft\Java Runtime Environment\1.4.2
      

  5.   

    我的是在hkey_localmachine 里找到的!