I assume you have a file. With java.awt.Desktop you can use something like this:
public static void openContaiingFolder(File file) { String absoluteFilePath = file.getAbsolutePath(); File folder = new File(absoluteFilePath.substring(0, absoluteFilePath.lastIndexOf(File.separator))); openFolder(folder); } public static void openFolder(File folder) { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(folder); } }
Be careful if you call this with a file that is not a directory, at least Windows will try to open the file with the default program for the file type.
But I do not know on which platforms this is supported.
Alexs source share