I am creating an application in which it would be very easy for a user to actually be able to click on a link in the application, which opens up a specific folder in Finder (in Mac)/ Windows Explorer. This can happen on click event of a link or a button.
Is there a way I can open these native OS applications (for a specific folder) via Swing?
Use
Runtime.getRuntime().exec("command here");to execute a command in the system on which java is running.For explorer.exe, you can simply pass the absolute path of the folder as an argument, e.g.
In Mac OS X, you can use the
opencommand:you can find out how to detect which OS You’re on, and hence which code to run, here. For example, this will chek if you are on windows: