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

Desktop.browse() not working correctly with image files

    Details

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

      Description

      OPERATING SYSTEM(S):
      --------------------
      Microsoft Windows XP Professional
      5.1.2600 Service Pack 2 Build 2600

      FULL JDK VERSION(S):
      --------------------
      java version "1.6.0_06"
      Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
      Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode)

      DESCRIPTION:
      ------------
      The browse() API of Desktop class is not working as expected while trying to open a file which is associated with "Windows Picture and Fax Viewer" i.e. "Open With" property of the image file is associated with "Windows Picture and Fax Viewer".

      It opens the image file (say sample.gif) specified but the window immediately gets closed. However if the image file is associated with other applications such as "Microsoft Photo Editor" or "Internet Explorer", the window launched by running the below program doesn't get closed i.e. behaving as expected.

      NOTE: If the image file is associated with "Windows Picture and Fax Viewer" and if you double click the image file, it opens properly and remains opened. It gets closed only when it is opened using the Desktop browse() API.

      Steps To Recreate The Issue:

      1. Compile and Run the below testcase using the above specified Sun
         Java 6.
      2. Specify the image file (say sample.gif) in the command line while
         running the testcase. i.e. "java DesktopTest sample.gif"
      3. Make sure that the image file that you specify is associated with
         the "Windows Picture and Fax Viewer" ie., "Open With" property of
         the image file should be associated with the Windows Picture and Fax
         viewer.
      4. It will launch the "Windows Picture and Fax viewer" to open the
         image file specified, however within few seconds the window will get
         closed.
      5. Expected Behavior ---> The launched "Windows Picture and Fax
         viewer" window should remain open with the image file specified.

      Note that the behaviour of the Desktop API in this scenario seems to depend on which machine we run it on. For the test described in this report we have seen the following results on different machines:

      1. The behaviour described here - i.e. Windows Picture and Fax Viewer
         opening but then closing immediately.
      2. A core dump.
      3. Nothing happening at all, regardless of which application GIF files
         are associated with.
      4. The GIF file being opened successfully, even with Windows Picture
         and Fax Viewer.

      Hence we believe this issue may be related to CRs 6599987 and 6508888, which described similar problems with the Desktop API, which are apparently related to Windows Service Pack 2.

      Testcase:
      ---------
      import java.awt.Desktop;
      import java.net.URI;
      import java.io.*;
      class DesktopTest{
        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();
      }
        }
      }

        Attachments

          Issue Links

            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: