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

java.awt.Desktop cannot open file with Windows UNC filename

    Details

    • Subcomponent:
    • Introduced In Build:
      b49
    • Introduced In Version:
      6
    • Resolved In Build:
      b31
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "1.6.0"
        Java(TM) SE Runtime Environment (build 1.6.0-b105)
        Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Microsoft Windows XP [version 5.1.2600]


        A DESCRIPTION OF THE PROBLEM :
        Hi,

        The java.awt.Desktop class does not allow to open a network file with blank character into the path. For example, it fails to open "//serverName/drive/Temp/my folder/a simple file.xxx", where xxx may be any extension : txt, pdf...

        For information, it works if the path contains the drive letter "N:/Temp/my folder/a simple file.txt", or if the path does not contain any blank like "//serverName/drive/Temp/my_folder/a_simple_file.txt".


        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Should open the file with the application used for its extension, like Notepad for txt file.
        ACTUAL -
        IOException

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        The ouput is:

        java.io.IOException: Failed to open file:////serverName/drive/Temp/my%20folder/a%20simple%20file.txt. Error message: Le chemin d'accès spécifié est introuvable.
                at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
                at sun.awt.windows.WDesktopPeer.open(Unknown Source)
                at java.awt.Desktop.open(Unknown Source)
                at Swing.myDesktop.main(jvDesktop.java:26)



        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        package Swing;

        import java.awt.*;
        import java.io.*;

        public class myDesktop
        {
        public static void main(String[] args)
        {
        try
        {
        Desktop myDesktop = null;
        if (Desktop.isDesktopSupported())
        myDesktop = Desktop.getDesktop();

        if (myDesktop != null)
        {
        // -> Works
        //File myFile = new File("//sma-nasft04-1/servev/Temp/my_folder/a_simple_file.txt");
        //File myFile = new File("N:/Temp/my folder/a simple file.txt");

        // -> Does not work
        File myFile = new File("//sma-nasft04-1/servev/Temp/my folder/a simple file.txt");

        if (myFile.exists())
        myDesktop.open(myFile);
        else
        System.out.println("This file is not a valid one");
        }
        }
        catch (IOException e)
        {
        e.printStackTrace();
        }
        }

        }

        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  alitvinov Anton Litvinov
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: