import javax.swing.JFileChooser; public class Main { public static void main(String[] args) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { java.io.File f = chooser.getSelectedFile(); System.err.println(f.getPath()); } } }