Login  Register

Re: MacOS 10.8 Java problems?

Posted by Kenneth Sloan on Mar 29, 2014; 5:20am
URL: http://imagej.273.s1.nabble.com/MacOS-10-8-Java-problems-tp5007118p5007130.html

Here’s a minimal program that tickles the error.  It works on everyone’s machine except mine (so..you might not want to spend any time on this).  My last (wrong) theory was that it had to do with an interaction between Sophos version 8 and Mac OS/X 10.9. But, fixing *that* did not fix *this*.  Current status is that the program worked correctly ONCE after a reboot, and then failed; I suspect this is repeatable, but have not had time to test (I re-worked the program that needed this, so it’s no longer on my critical path).

Failure mode is that the OpenDialog box is invisible. The program behaves as if the dialog box has been displayed and is waiting for input.  The program displays “calling showOpenDialog” and sits quietly, waiting for showOpenDialog to return.

Note that this might be an improper use of Swing code without actually firing up Swing - but the docs say it’s legal, and it has worked for a long time.

MacOS/X 10.9.2, Java 7 - both installed at the same time.  Again - it works on other machines.  
==============
// File: OpenDialogTest.java
// Author: K R Sloan
// Last Modified: 24 March 2014
// Purpose: minimal program demonstrating bug

import java.util.*;
import java.io.*;
import javax.swing.*;
import javax.swing.filechooser.*;
import java.lang.*;

public class OpenDialogTest
{
   public static void main(String[] args) throws FileNotFoundException, Exception
    {
        JFileChooser chooser = new JFileChooser(".");
        FileNameExtensionFilter javaFilter
            = new FileNameExtensionFilter("Java Source Code","java");
        chooser.setFileFilter(javaFilter);
        chooser.setDialogTitle("Java Files");


        System.out.printf("calling showOpenDialog\n");
        int returnVal = chooser.showOpenDialog(null);
        System.out.printf("showOpenDialog returned %d\n", returnVal);


        if (returnVal != JFileChooser.APPROVE_OPTION)
            throw new Exception("no file chosen");
    }
}
==============
--
Kenneth Sloan
[hidden email]


On Mar 28, 2014, at 16:24 , Johannes Schindelin <[hidden email]> wrote:

> Hi Kenneth,
>
> On Fri, 28 Mar 2014, Kenneth Sloan wrote:
>
>> I haven’t (yet) had any issues with FIJI,
>
> obviously due to Fiji still relying on Java 6 on MacOSX ;-)
>
>> but I have seen serious problems with showOpenDialog() in stand-along
>> java programs (10.9.2, Java 7).
>
> Care to share anything in the way of details?
>
> Ciao,
> Johannes


--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html