4 Replies Latest reply: May 5, 2014 4:48 AM by gimbal2 RSS

    JavaFX Freeze on Desktop.open(file), Desktop.browse(uri)

    WrenX

      I’m running some code in Java on Ubuntu 12.04 LTS 64 Bit (with Gnome Shell), using Oracle JDK 1.8.0_05 via NetBeans8.0.

      The following function works perfectly when called either in Main or in an otherwise empty Java Project, however when called from any JavaFX application, it causes the window to freeze and stop responding (although the project complies perfectly), requiring it to be Force Closed.

      Can anyone suggest any issues with what I’ve written which might be causing an issue or loop?

      Alas, due to the mode of failure, there is no error message that I can supply or analyse.

      Any suggestions gratefully received, thanks in advance.

      public static void desktopTest(){

           Desktop de = Desktop.getDesktop();

           try {

                de.browse(new URI("https://community.oracle.com/"));

           }

           catch (IOException | URISyntaxException e) {

                System.out.println(e);

           }

           try {

                de.open(new File("/home/aaa/file.ext"));

           }

           catch (IOException e){

                System.out.println(e);

           } try {

                de.mail(new URI("mailto:email@example.com"));

           }

           catch (URISyntaxException | IOException e){

                System.out.println(e);

           }

      }

        • 1. Re: JavaFX Freeze on Desktop.open(file), Desktop.browse(uri)
          rp0428

          So what is stopping you from troubleshooting the problem?

           

          You haven't indicated that you have done ANYTHING to try to determine the cause.

           

          1. the code will try to do three different things.

          2. it freezes.

          3. you don't know WHICH of the three things it is trying to do when it freezes

           

          So the obvious first step is to determine WHICH of the three things is causing it to freeze.


          A typical cause is permission or privilege problems haven't been granted properly or at all.

          • 2. Re: JavaFX Freeze on Desktop.open(file), Desktop.browse(uri)
            WrenX

            The same result happens with any of the three, hence my inclusion of all them -- and of course, logically, it can't be any of them because, if it were the third, the first and second would still run, and if it were the second the first would still fire successfully.

             

            And it's not trying to do three different things, it's trying to do one thing, then trying to do one thing, then trying to do one thing, but failing on any of them. To clarify, "Each of the Desktop methods simply cause the application to Freeze".

             

            So perhaps I should have written:

             

            Calling any of :-

                  public static void desktopTestBrowse(){

                       Desktop de = Desktop.getDesktop();

                       try {

                            de.browse(new URI("https://community.oracle.com/"));

                       }

                       catch (IOException | URISyntaxException e) {

                            System.out.println(e);

                       }

                  }

            And,

                  public static void desktopTestOpen(){

                      Desktop de = Desktop.getDesktop();

                      try {

                            de.open(new File("/home/aaa/file.ext"));

                       }

                       catch (IOException e){

                            System.out.println(e);

                       }

                  }

            And,

                 public static void desktopTestMail(){

                       Desktop de = Desktop.getDesktop();

                       try {

                            de.mail(new URI("mailto:email@example.com"));

                       }

                       catch (IOException | URISyntaxException e) {

                            System.out.println(e);

                       }

                  }

             

            All cause the application to hang.

             

            I've already done the the troubleshooting to know that it'll hang purely if it's fired after the FXML has loaded, and that calling any from "Main()", or from a non-Gui Java Application, or Swing GUI works as expected. So again, I know that it's specifically an issue with JavaFX; this is known-working code, on this machine with this JDK/JVM.

             

            Are there any inherent permission differences between JavaFX calls/threads and standard ones?

            • 4. Re: JavaFX Freeze on Desktop.open(file), Desktop.browse(uri)
              gimbal2

              WrenX wrote:

               

              Any suggestions?

              Can you reproduce the problem on other machines? If so: file a bug report.

               

              Note: you should first check if you can reproduce on Java 7 - if not then it might be a regression in Java 8. That's valuable information to be able to provide.