Reputation: 153
I am writing an eclipse plugin, and one of the features I need is to open the OS native file explorer on a given folder. I couldn't find a solution with various searches...
Basically I have an IPath (or string) with a folder name. I need to open explorer.exe on Windows and whatever there is on Linux for that folder/directory.
Is there a way to do this?
Thanks, Oren
Upvotes: 1
Views: 408
Reputation: 36894
You can use the Program
class of SWT. The launch(String)
method in particular will do what you want:
Launches the operating system executable associated with the file or URL (http:// or https://). If the file is an executable then the executable is launched. Note that a Display must already exist to guarantee that this method returns an appropriate result.
This will do:
public static void main(String[] args)
{
DirectoryDialog dialog = new DirectoryDialog(new Shell());
String path = dialog.open();
if(path != null)
{
Program.launch(path);
}
}
Upvotes: 2