2 Replies Latest reply: Jun 28, 2010 5:17 PM by 807580 RSS

    Open file doesn't work on Windows 7

    807580
      Hello ,

      I have this portion of code that should open a file and let windows decide what program to use for that :

      Code 1 : Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"c:/x.xls");

      Code 2 : File f = new File("c:/x.xls");
      Desktop.getDesktop().open(f);


      None of this options opens the file , no error is caught , no nothing.
      The result of RUN si "Buid succesfull".

      Bouth CODE 1 and CODE 2 work on Windows Xp.

      Do you have any suggestions ?

      Thank you for your help !
        • 1. Re: Open file doesn't work on Windows 7
          DarrylBurke
          Works fine for me. The actual code lines I tested with:
          try {
            Desktop.getDesktop().open(new File("E:/drb/Docs/Personal/April2009.xls"));
          } catch (IOException ex) {
            ex.printStackTrace();
          }
          Microsoft Windows [Version 6.1.7600]
          Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
          
          C:\Users\Darryl>java -version
          java version "1.6.0_17"
          Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
          Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
          
          C:\Users\Darryl>
          db
          • 2. Re: Open file doesn't work on Windows 7
            807580
            Thank you very much.

            That code works fine , i don't know why mine didn't.
            My java -version is the latest.

            Question answered , problem rezolved.

            Thank you ,

            Best regards,
            V.G