Search code examples
javawindowsswingntfsjfilechooser

JFileChooser and NTFS JunctionPoints / Symlinks?


The JFileChooser in Swing (Java 1.6.0_u25) doesn't seem to know how to deal with NTFS Junction Points or Symbolic Links.

The file chooser has no special handling:

int rv = mainfileChooser.showOpenDialog(parentFrame)

When using this on a Windows 7 box, the special folders under My Documents (My Pictures, My Videos, My Music) can't be entered - the user clicks on them, but nothing happens and they can't be selected. After some experimentation, the same thing happens with any SymLink or Junction Point (both pre-generated by the OS and manually created.)

.lnk Shortcuts to directories work fine.

Is there a way to fix this and let my users save images in "My Pictures"?


Solution

  • By an amazing coincidence, Java 1.6u27 just shipped, and includes a fix for this very issue!

    Release Notes: http://www.oracle.com/technetwork/java/javase/2col/6u27bugfixes-444150.html

    Bug Writeup: https://bugs.java.com/bugdatabase/view_bug?bug_id=7012783

    The bug discussion revolves around DFS links, rather than Junction points, but I believe the issues are the same, and testing this locally all the wacky behavior has gone away and I can save to My Pictures (and friends) just fine.