Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6833958

Desktop browser does not work as expected on Ubuntu

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux

      Description

      OPERATING SYSTEM(S):
      Linux (Ubuntu)

      FULL JDK VERSION(S):
      1.6.0_13

      STEPS TO REPRODUCE:

      1. Create file called "abc.xyz" & opens it with "gedit".

      2. Change the associated registered application: Right click on the file
         and select properties. Go to "opens with" tab and select "firefox".

      3. Compile and run Hello.java, compile it and run as follows.
           javac Hello.java
           java Hello abc.xyz


      TESTCASE
      --------
      import java.awt.Desktop;
      import java.net.URI;
      import java.io.*;

      class Hello {
          public static void main(String args[]) {
              Desktop desktop = null;
              if (Desktop.isDesktopSupported()) {
                  try {
                      desktop = Desktop.getDesktop();
                  } catch (Exception he) {
                      System.out.println("GraphicsEnvironment is headless, got a Headless Exception");
                  }
              } else {
                  System.out.println("Desktop class is not supported on this platform");
              }

              try {
                  File file = new File(args[0]);
                  URI uri = file.toURI();

                  if (uri != null) {
                      //System.out.println(uri.toURL());
                      desktop.browse(uri);
                  } else {
                      System.out.println("URI is null");
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }

          }
      }


      Observed Result:
      It is still uses "gedit" to open abc.xyz.

      Expected Result:
      It should use firefox to open the file.

      ANALYSIS
      --------
      The behaviour can be replicated with a standalone C testcase:

      #include <stdio.h>
      #include <dlfcn.h>

      typedef int gboolean;
      gboolean (*gnome_url_show) (const char *url, void **error);

      int main() {
          void *gnome_handle;
          void *vfs_handle;
          gboolean (*gnome_vfs_init) (void);
          vfs_handle = dlopen("libgnomevfs-2.so.0", RTLD_LAZY);

          if (vfs_handle == NULL) {
              printf("\n cannot load libgnomevfs");
              return 0;
          }

          gnome_vfs_init = dlsym(vfs_handle, "gnome_vfs_init");

          if (gnome_vfs_init == NULL) {
              printf("\n gnome_vfs_init is NULL ");
              return 0;
          }

          (*gnome_vfs_init)();
          gnome_handle = dlopen("libgnome-2.so.0", RTLD_LAZY);

          if (gnome_handle == NULL) {
              printf("\n cannot load libgnome-2.so.0 ");
              return 0;
          }

          gnome_url_show = dlsym(gnome_handle, "gnome_url_show");

          if (gnome_url_show == NULL) {
              printf("\n gnome_url_show is null ");
              return 0;
          }

          gnome_url_show("file:/root/Desktop/testcase.txt",NULL);
          printf("\n AFter showing console");
          return 0;
      }

      Therefore this appears to be an issue with the OS call gnome_url_show(). However, this API is deprecated and the issue will not be fixed. We have been advised that gtk_show_uri() should be used instead. The JDK implementation should be modified to use the new API.

        Attachments

          Activity

            People

            • Assignee:
              denis Denis Fokin (Inactive)
              Reporter:
              dkorbel David Korbel (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: