如题

解决方案 »

  1.   

    我不了解你的问题,但Applet中可以这样实现   
        
      URL   url   =   new   URL(applet.getDocumentBase(),   "http://....");   
      applet.getAppletContext().showDocument(url,"Test"   );
      

  2.   

    楼主有点不明白你的意思。import java.lang.reflect.Method;
    import javax.swing.JOptionPane;
    /**
    * java打开浏览器
    * @author wzf
    * 2008-7-23 上午09:16:23
    */
    public class URLOpener
    {
    /**
      * test
      * @param args
      */
    public static void main(String args[])
    {
      openURL("");
    }
    /**
      *
      * @param url
      */
    public static void openURL(String url)
    {
      String osName = System.getProperty("os.name");
      try {
       if(osName.startsWith("Mac OS"))
       {
        //doc
        Class fileMgr = Class.forName("com.apple.eio.FileManager");
        Method openURL = fileMgr.getDeclaredMethod("openURL",new Class[] {String.class});
        openURL.invoke(null, new Object[] {url});
       }
       else if(osName.startsWith("Windows"))
       {
        //Windows
        Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
       }
       else
       {
        //assume Unix or Linux
        String[] browsers = {
          "firefox", "opera", "konqueror",
          "epiphany", "mozilla", "netscape"};
        String browser = null;
        for(int count = 0; count < browsers.length && browser == null;count++)
        {
         if(Runtime.getRuntime().exec(
           new String[] {"which", browsers[count]}).waitFor() == 0)
         {
          browser = browsers[count];
         }
        }
        if(browser != null)
        {
         Runtime.getRuntime().exec(new String[] {browser, url});
        }
       }
      }
      catch(Exception ex)
      {
       ExpWork.doExp(ex);
      }
    }
    }
      

  3.   

    java本来就是跨系统的,任何系统装个jvm都是一样的,不存在在那个系统环境下
      

  4.   

    这句话对,但要分情况而定
    lz试试看
    Runtime.getRuntime().exec("/usr/bin/firefox " + url);
      

  5.   

    方法有很多的:
    public static void main(String[] a) {
    try {
    URI uri = new URI("http://www.baidu.com");
    Desktop desktop = null;
    if (Desktop.isDesktopSupported()) {
    desktop = Desktop.getDesktop();
    }
    if (desktop != null)
    desktop.browse(uri);
    } catch (IOException ioe) {
    ioe.printStackTrace();
    } catch (URISyntaxException e) {
    e.printStackTrace();
    }
    }
      

  6.   

    Desktop 需要jdk1.6支持的,对于Runtime.getRuntime().exec(),安全性不是很好,不知道还有没有其他方法
      

  7.   

    能够解释一下这句 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler"+ url);它是如何找到windows下默认的浏览器的
      

  8.   


    public static void openURL(String url) {
            try {
                browse(url);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Error attempting to launch web browser:\n" + e.getLocalizedMessage());
            }
        }    private static void browse(String url) throws ClassNotFoundException, IllegalAccessException,
                IllegalArgumentException, InterruptedException, InvocationTargetException, IOException,
                NoSuchMethodException {
            String osName = System.getProperty("os.name", "");
            if (osName.startsWith("Mac OS")) {
                Class fileMgr = Class.forName("com.apple.eio.FileManager");
                Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
                openURL.invoke(null, new Object[] { url });
            } else if (osName.startsWith("Windows")) {
                Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
            } else { // assume Unix or Linux
                String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
                String browser = null;
                for (int count = 0; count < browsers.length && browser == null; count++)
                    if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
                        browser = browsers[count];
                if (browser == null)
                    throw new NoSuchMethodException("Could not find web browser");
                else
                    Runtime.getRuntime().exec(new String[] { browser, url });
            }
        }
      

  9.   

    楼上这段代码部署到linux服务器后,在windows下访问,怎么没有反应