Cross-Platform File Opening Issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • russellelly
    New Member
    • Mar 2008
    • 2

    Cross-Platform File Opening Issue

    Hi all,

    Just spent some hours banging my head on a brick wall with this one. I've got a program where I have to open a file given its pathname as a String. I've got code that works fine on Mac and Linux, but it'll only work on Windows XP for certain file types - for example .m4a will open with iTunes quite happily, but .avi produces this error:

    Code:
    java.io.IOException: Failed to open file:/C:/Documents%20and%20Settings/Chris/Desktop/In.Treatment.S01E21.avi. Error message: The parameter is incorrect.
    
    at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
    at sun.awt.windows.WDesktopPeer.open(Unknown Source)
    at java.awt.Desktop.open(Unknown Source)
    (the stack trace goes on a while, but I won't type it all out unless more is needed)

    The bit of code causing this is:

    Code:
    try {d.open (new java.io.File(path));} // path is a String with a pathname
    catch(Exception ex) {ex.printStackTrace();}
    I've tried this with the default application for .avi being Windows Media Player and VLC (that error is with the latter set, the former gives a similar but slightly different error). Does Windows XP just not fully support the java.awt.Deskto p class?

    Any ideas very welcome! :)
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by russellelly
    Hi all,

    Just spent some hours banging my head on a brick wall with this one. I've got a program where I have to open a file given its pathname as a String. I've got code that works fine on Mac and Linux, but it'll only work on Windows XP for certain file types - for example .m4a will open with iTunes quite happily, but .avi produces this error:

    Code:
    java.io.IOException: Failed to open file:/C:/Documents%20and%20Settings/Chris/Desktop/In.Treatment.S01E21.avi. Error message: The parameter is incorrect.
    
    at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
    at sun.awt.windows.WDesktopPeer.open(Unknown Source)
    at java.awt.Desktop.open(Unknown Source)
    (the stack trace goes on a while, but I won't type it all out unless more is needed)

    The bit of code causing this is:

    Code:
    try {d.open (new java.io.File(path));} // path is a String with a pathname
    catch(Exception ex) {ex.printStackTrace();}
    I've tried this with the default application for .avi being Windows Media Player and VLC (that error is with the latter set, the former gives a similar but slightly different error). Does Windows XP just not fully support the java.awt.Deskto p class?

    Any ideas very welcome! :)

    About the error, try to change '/' to '\'...

    Code:
    file:/C:/Documents%20and%20Settings/Chris/Desktop/In.Treatment.S01E21.avi

    Comment

    Working...