Anyone had any success with <Desktop>.open() in 1.6?

Discussion in 'Java' started by Lee Weiner, Mar 5, 2006.

  1. Lee Weiner

    Lee Weiner Guest

    I've been playing around with the new Desktop class in 1.6. I've
    gotten the mail() and browse() methods to work as advertised, but
    not the open() method. Example code:

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

    public class DesktopTest
    {
    public static void main ( String[] args )
    {
    System.out.println( "Desktop supported?: " +
    Desktop.isDesktopSupported() );
    Desktop desk = Desktop.getDesktop();

    try
    {
    File file = new File( "d:\\basic.txt" );
    System.out.println( "File exists?: " + file.exists() );
    desk.open( file );
    }
    catch( IOException exc )
    {
    System.out.println( exc.getMessage() );
    }
    }
    }

    Both println's display "true", but I get no window, no exception,
    no nuttin'. Also tried the edit() method with same results. Text
    files are associated with Notepad on my system. If I double-click
    basic.txt in Windows Explorer, Notepad opens.

    Lee Weiner
    lee AT leeweiner DOT org
    Lee Weiner, Mar 5, 2006
    #1
    1. Advertising

  2. Lee Weiner

    IchBin Guest

    Lee Weiner wrote:
    > I've been playing around with the new Desktop class in 1.6. I've
    > gotten the mail() and browse() methods to work as advertised, but
    > not the open() method. Example code:
    >
    > import java.awt.Desktop;
    > import java.io.*;
    >
    > public class DesktopTest
    > {
    > public static void main ( String[] args )
    > {
    > System.out.println( "Desktop supported?: " +
    > Desktop.isDesktopSupported() );
    > Desktop desk = Desktop.getDesktop();
    >
    > try
    > {
    > File file = new File( "d:\\basic.txt" );
    > System.out.println( "File exists?: " + file.exists() );
    > desk.open( file );

    [snip code]
    Try this..
    Desktop.open( file );
    --

    Thanks in Advance...
    IchBin, Pocono Lake, Pa, USA
    http://weconsultants.servebeer.com/JHackerAppManager
    __________________________________________________________________________

    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
    IchBin, Mar 5, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robbo
    Replies:
    0
    Views:
    374
    Robbo
    Oct 29, 2003
  2. LP
    Replies:
    3
    Views:
    362
    Brian Bischof
    Feb 17, 2005
  3. Ryan
    Replies:
    0
    Views:
    320
  4. Alex Hunsley
    Replies:
    4
    Views:
    510
    Toby Reyelts
    Oct 17, 2004
  5. Sean Peterson
    Replies:
    2
    Views:
    791
Loading...

Share This Page