I have two 2012, non-retina 13" MacBook Pros. They're both running OS X 10.9.0 and both have Java runtime 1.7.0_45.
This is packaged as a jar. If it is ran using
Then on one Mac, the following always appears:
The menubar changes to have the title of the jar, the java icon gets added to the dock, and the picker appears. Once the user selects a file, it says
On the other Mac, it only behaves that way if you execute it using sudo.
If you don't use sudo, it'll display the first message, the java icon gets added to the dock, and the menubar changes to have the title of the jar, but the picker never appears. Expose doesn't show the picker (it does otherwise.) No error messages are output.
On both computers the user logged in is an admin. The computers are so similarly set up I can't think of anything that might be causing the issue. Permissions are set up the same. Any suggestions on what might be causing this inconsistency?
Edit: Tried on a third 2012 MacBook Pro running Mavericks and the same version of Java. It works just fine without sudo, same as the first.
Code:
public static void main(String[] args) {
try {
JFileChooser picker = new JFileChooser();
picker.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
picker.setMultiSelectEnabled(true);
picker.setFileView(new FileView() {
@Override public Boolean isTraversable(File file) {
if (file.isDirectory() && file.getName().startsWith("my-prefix")) {
return false;
}
return null;
}
});
System.out.println("About to show the file picker.");
if (picker.showOpenDialog(null) == JFileChooser.APPROVE_OPTIONS) {
for (File file : picker.getSelectedFiles()) {
openFile(file);
}
} else {
System.exit(0);
}
System.out.println("File picker shown successfully.");
} catch (Exception e) {
System.out.println("Failed to show file picker.);
e.printStackTrace();
}
}
This is packaged as a jar. If it is ran using
Code:
java -jar (path to jar)
Then on one Mac, the following always appears:
Code:
About to show the file picker.
The menubar changes to have the title of the jar, the java icon gets added to the dock, and the picker appears. Once the user selects a file, it says
Code:
File picker shown successfully.
On the other Mac, it only behaves that way if you execute it using sudo.
If you don't use sudo, it'll display the first message, the java icon gets added to the dock, and the menubar changes to have the title of the jar, but the picker never appears. Expose doesn't show the picker (it does otherwise.) No error messages are output.
On both computers the user logged in is an admin. The computers are so similarly set up I can't think of anything that might be causing the issue. Permissions are set up the same. Any suggestions on what might be causing this inconsistency?
Edit: Tried on a third 2012 MacBook Pro running Mavericks and the same version of Java. It works just fine without sudo, same as the first.
Last edited: