从Java打开网页时出现Firefox错误消息

时间:2017-06-15 23:02:33

标签: java firefox ubuntu-14.04

当我从Firefox 54.0版的Java程序打开网页时,我收到一条不寻常的错误消息。使用Ubuntu 14.04运行程序时发生错误。使用MacOS 10.12.5或Windows 10运行相同版本的Firefox时不会发生此错误。

打开网页的源代码是:

import java.net.URI;
import java.net.URL;
import java.awt.Desktop;

class Example
  {  
   public static void main(String args[])
     {
      System.out.println(">>> Example Start");  
      try
        { openWebpage(new URL("http://stackoverflow.com")); }
      catch (Exception e)
        { e.printStackTrace(); }
      System.out.println("<<< Example End");  
     }  

    public static void openWebpage(URL url) 
      {
       Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
       if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) 
         {
          try
            {
             URI uri = url.toURI(); 
             desktop.browse(uri); 
            } 
          catch (Exception e)
            { e.printStackTrace(); }
         }
      }
  }

我得到的错误:

$ javac Example.java
$ java Example
>>> Example Start
<<< Example End

(firefox:20377): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed

(firefox:20377): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed

(firefox:20377): GLib-GObject-CRITICAL **: g_object_ref: assertion 'object->ref_count > 0' failed

(firefox:20377): GLib-GObject-CRITICAL **: g_object_unref: assertion 'object->ref_count > 0' failed
$

当我使用Chromium作为默认浏览器时,我没有看到相同的错误。

0 个答案:

没有答案