0

I have one large group of users that cannot launch a locally created file (PDF, Word, etc.) from within a signed applet. Double clicking the file from Windows Explorer launches it so the file association to the launching app is known. Tech support logs in remotely on a machine with UAC enabled and sees no problem loading the applet and can launch the local file without a problem. This makes me think the large group has a common local setting. Users are running Java 1.6u31 on Windows XP (or 7, not sure). There is no error displayed and nothing in the java console (all hearsay since I do not see the problem). Any suggestions for what local PC settings that may cause this behavior? Per the code, it looks like the problem is Desktop is supported, but Desktop.Action.OPEN is not. Any suggestions why? Thanks.
I am using the following to launch the file:

            /*
            //old way that would work for Windows prior to Java 1.6
            //cmd = System.getenv("windir") +"\\system32\\"+"rundll32 SHELL32.DLL,ShellExec_RunDLL " + cmd;
            //cmd = "open "+cmd;  // Mac for PDF only?
            //try{
            //  Runtime.getRuntime().exec(cmd);
            //} catch (Exception e) {
            //  //handle error
            //}
            */
            Desktop desktop = null;
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
                if (desktop.isSupported(Desktop.Action.OPEN)) {
                    try {
                        desktop.open(new File(file));
                        return;
                    } catch (IOException e) {
                        //Error launching the file
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(theFrame,
                            "Unable to launch the file.",
                            "Document Error", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                }
            } else {
                //This OS cannot launch the file
                JOptionPane.showMessageDialog(theFrame,
                        "This operating system is unable" +
                        "\nto launch external files" +
                        "\nfrom within this application.",
                        "Document Error", JOptionPane.ERROR_MESSAGE);
                    return;
            }
James
  • 133
  • 9
  • I see why the user sees nothing: Desktop is supported, but Desktop.Action.OPEN is not and I do not display a helpful message. So the question is really what local setting would cause this behavior? Is it a Windows configuration or Java? Thanks again! – James Aug 23 '12 at 21:10

1 Answers1

0

Pure guesses:

1) the affected users are all on Windows 7

2) Vista/Win 7 "UAC" is biting you:

SUGGESTION (diagnostic only):

Find one of the affected users, try disabling UAC, and see if it "suddenly starts working"

Control Panel->User Accounts->Turn User Account Control off

==================================================================================

Addendum 8/24/2012:

1) I understand from your subsequent notes that you're not just trying to execute a program - you're actually trying to invoke a Windows file association (i.e. "shell open" a .pdf should fire off an instance of "AcroReader").

2) Look at this link:

3) Update your JDIC (if necessary)

4) Add a couple of test buttons to your applet:

a) "open" notepad.exe (see if you can directly invoke an .exe by name)

b) "open" somefile.txt (see if you can invoke any file associations - like "notepad" for ".txt")

5) If none of the above leads to a solution, get direct access to one of the "failing PCs" so that you can debug "hands on".

'Hope that helps!

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • I found that issue as well after I posted but I don't think that is it. I have multiple accounts on my own Win 7 machine and have UAC set to the most restrictive level "Always Notify" and I am NOT seeing the problem. However, I will ask the tech to suggest it anyway. I also found a reference to MagicISO at http://stackoverflow.com/questions/11774247/why-desktop-open-doesnt-work-with-magiciso-being-installed and have asked about that as well. Thanks. – James Aug 23 '12 at 21:52
  • What type of file is being launched? I run Windows 7 and have UAC enabled, but have never tried using it to launch an executable. I imagine they would be the only things UAC would prompt for. – Andrew Thompson Aug 23 '12 at 23:37
  • No executables. It would be user created files like PDF, Word, Excel, etc. The user creates and uploads the file and the applet allows the user to verify the file they just uploaded is the correct one by launching it from a button. The button was requested by the users, so don't judge me by my interface! Thanks. – James Aug 24 '12 at 13:58
  • Thanks for looking further into this. RE 2) the problem is the same but no solution was presented. RE 3) "Update your JDIC", not sure what to do here. Users should have standard JRE 1.6u31 or newer (or 1.7.x). I thought the Desktop object was included in the standard install. RE 4) Me on a local dev environment and tech support downloading the same jar as the problem user do NOT see the problem so adding buttons locally on a dev server won't help me (and I cannot ask the problem user to log into my dev server unless I get really desperate). Still looking... Thanks. – James Aug 27 '12 at 14:04
  • @paulsm4 Thanks. This is still a problem. I am using Remote Desktop with an admin account to a client XP computer with the problem. "desktop.open(x);" is not throwing an exception. Debugging before/after it print with nothing in between but no file opens. I have tried shutting down some services, virus protection, and terminating things in Task Manager. All have no effect on this XP machine and I still see no error on my own machine when running the same app. I saw references to problems with MagicIso but that is not on this computer. Any other suggestions will be greatly appreciated! – James Oct 15 '12 at 22:41