Open up windows explorer in java

Michael Scott picture Michael Scott · Jun 24, 2012 · Viewed 9.6k times · Source

I have been looking for an answer to this on Stack Overflow, but I couldn't find an answer that worked for me.

Using Java, how do I create a button that will launch an Explorer Window to a specified directory? If this is possible, how do I make it work for OSX and Linux?

Answer

Pshemo picture Pshemo · Jun 24, 2012

I am not sure how it works in other OS but in Windows you can use something like this

Desktop.getDesktop().open(new File("c:\\"));

Edit

Found another way (check link to FileExplorer class from that answer). Also you can use System.getProperty("os.name") to determine operation system.